mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

孤人 提交于 2019-11-26 04:56:07

问题


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

it is throwing an error- 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:


You need to check the return value of 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.

If mysql_query fails it returns boolean false instead of a resource.

When you pass this boolean value to mysql_num_rows you get this error.



来源:https://stackoverflow.com/questions/3698740/mysql-num-rows-supplied-argument-is-not-a-valid-mysql-result-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!