mysql_num_rows():提供的参数不是有效的MySQL结果资源

时间:2010-09-13 08:12:52

标签: php sql mysql warnings mysql-num-rows

if(mysql_num_rows($result))
{
echo "no match found!";
}

它正在抛出一个错误 - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\Hosting\6448289\html\includes\getQuestion.php on line 72

1 个答案:

答案 0 :(得分:5)

您需要检查mysql_query

的返回值
$query = 'YOUR QUERY';
$result = mysql_query($query);
if (!$result) {
    trigger_error('Invalid query: ' . mysql_error()." in ".$query);
}
// go ahead and fetch the results using mysql_num_rows.

如果mysql_query失败,则返回boolean false而不是resource

将此boolean值传递给mysql_num_rows时,会出现此错误。