<?PHP
header("Content-Type: text/html; charset=utf-8");
include('conn.php');//链接数据库
ini_set("display_errors","On");
error_reporting(E_ALL);
$tel = $_POST['tel'];//post获得用户名表单值
$password = $_POST['password'];//post获得用户密码单值
echo $tel;
echo $password;
if ($tel && $password){//如果用户名和密码都不为空
$sql = "select * from user where tel = '$tel' and password = '$password' ";//检测数据库是否有对应的tel和password的sql
$res = mysql_query($sql);//执行sql
$rows = mysql_num_rows($res);//返回一个数值
echo $sql;
echo $res;
if($rows){//0 false 1 true
header("refresh:0;url=index.html");//如果成功跳转至index.html页面
exit;
}else{
echo "用户名或密码错误";
echo "
<script>
setTimeout(function(){window.location.href='login.html';},1000);
</script>";
//如果错误使用js 1秒后跳转到登录页面重试,让其从新进行输入
}
}else{//如果用户名或密码有空
echo "没有获取到手机号或者密码";
echo "
<script>
setTimeout(function(){window.location.href='login.html';},1000);
</script>";
//如果错误使用js 1秒后跳转到登录页面重试,让其从新进行输入
}
mysql_close();//关闭数据库
?>
上面是login连接数据库进行登录,报Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in login.php on line 17 这个错误,该怎么修改?