可能重复:
PHP (MySQL) error : “Warning: mysql_num_rows() expects parameter 1 to be resource”
我的代码出现了令人讨厌的错误..
48. mysql_select_db("serverip_gamepwn", $con);
49. $username_session = $_COOKIE['GamePwN_LOL_Username'];
50. $username_session = mysql_real_escape_string($username_session);
51. $result = mysql_query("SELECT * FROM orders WHERE username='$username_session'");
52. $count = mysql_num_rows($result);
53. if($count != 1){
错误代码是:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/serverip/public_html/gamepwn.net/lol/status.php on line 52
答案 0 :(得分:1)
替换
$count = mysql_num_rows($result);
与
$count = mysql_num_rows($result) or die(mysql_error());
看看它的内容
答案 1 :(得分:0)
$result
无效Resultset,可能您的查询包含语法错误,因此结果变为false
。您可以通过mysql_error()
答案 2 :(得分:0)
//use this way it will workout
$result = mysql_query("SELECT * FROM orders WHERE username= '".$username_session."'");
$count = mysql_num_rows($result);
//now the count will be one
if($count != 1){
}else{
}