mysql_num_rows():提供的参数不是有效的MySQL结果资源 [英] mysql_num_rows(): supplied argument is not a valid MySQL result resource

查看:188
本文介绍了mysql_num_rows():提供的参数不是有效的MySQL结果资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

您需要检查 mysql_query

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.

如果mysql_query失败,它将返回boolean false而不是resource.

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

当您将此boolean值传递给mysql_num_rows时,会出现此错误.

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

这篇关于mysql_num_rows():提供的参数不是有效的MySQL结果资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆