您好,我目前遇到此代码的问题,我不确定将其他代码放在哪里。错误是这样的:
mysql_num_rows() expects parameter 1 to be resource, boolean given in
这是我的代码:
if ($_POST['submit'])
{
$username = $_POST['id'];
$password = $_POST['pass'];
//connect to the database here
$username = mysql_real_escape_string($username);
$query = "SELECT hashpass, salt
FROM users
WHERE username = '$username'";
$result = mysql_query($query);
if(mysql_num_rows($result) < 1) //no such user exists
{
echo "NO USER!";
}
$userData = mysql_fetch_array($result, MYSQL_ASSOC);
$hash = sha1 ( $userData['salt'] . $password );
if($hash != $userData['password']) //incorrect password
{
echo "WRONG PASS";
}
}
将不胜感激任何帮助。