输入用户名和密码时出现错误
mysql_num_rows():提供的参数不是有效的 MySQL 结果资源
它是说我没有选择数据库...
我想知道这个错误是什么意思。可能是连接到数据库的问题还是语法问题。这是用户名和密码的代码
$query = mysql_query("SELECT * FROM Users WHERE username = '$user'");
$numrows = mysql_num_rows($query);
if($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$dbuser = $row['username'];
$dbpass = $row['password'];
$dbactive = $row['active'];
if($password == $dbpass){
if($dbactive == 1){
//set session info
$_SESSION['userid'] = $dbid;
$_SESSION['username'] = $dbuser;
echo "You have been logged in as <b>$dbuser</b> Click here to go to member page.";
}else
echo "You must activate your account to login.";
}else
echo "You did not enter the correct password.";
}else
echo "The username you entered was not found.";
}
}else
echo "You must enter your username.";
}
问题出在 $query 行中。第一行