您好我的网页checklogin_admin.php:
有这个问题这是我的代码:
<?php
$host="localhost"; // Host name
$username="xxx"; // Mysql username
$password="xxx"; // Mysql password
$db_name="db_mp_reports"; // Database name
$tbl_name="tb_admin_users"; // Table name
// Connect to server and select databse.
@mysql_connect("$host", "$username", "$password")or die("cannot connect");
@mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$username=$_POST['username_'];
$password=$_POST['password_'];
// To protect MySQL injection
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $username and $password, table row must be 1 row
if($count==1){
//header("location:menu.html");
echo "Yes";
}
else {
echo "Wrong Username or Password, You do not have permission to access this site";
//header("location:error_login.html");
}
?>
这就是我的错误:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\... on line 26
Wrong Username or Password, You do not have permission to access this site