执行此php文件时出错

时间:2013-03-18 15:23:40

标签: php mysql

  

警告:mysql_fetch_assoc()期望参数1是资源,   第14行的F:\ Softwares \ xampp \ htdocs \ login-check.php中给出的整数   连接错误

代码:

<?php
session_start();
if(isset($_SESSION['username']))
{
header("location:home.php");
}
else
{
$user=$_POST['mailid'];
$pass=$_POST['password'];
$con=mysqli_connect("127.0.0.1","rahulk","","weltit");
$get=mysqli_query($con,"SELECT * FROM mem WHERE mailid='$user' AND password='$pass'");
$check=mysqli_num_rows($get);
if ($result=mysql_fetch_assoc($check))
{
$check_pass=$result['password'];
$check_user=$result['mailid'];
if ($check_pass==$pass &&  $check_user==$user)
{
echo "matched";
}
else
{
echo "wrong pass";
}
}
else
{
echo "connection error";
}
}
?>

2 个答案:

答案 0 :(得分:0)

mysql_fetch_assoc($check)应为mysql_fetch_assoc($get)。你不能得到行数的结果。

答案 1 :(得分:0)

mysql_fetch_assoc($check)

上面应该是

mysql_fetch_assoc($get)