Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在MySQL\u fetch\u数组($result)中检测$result是否是有效的MySQL结果资源_Php_Mysql - Fatal编程技术网

Php 如何在MySQL\u fetch\u数组($result)中检测$result是否是有效的MySQL结果资源

Php 如何在MySQL\u fetch\u数组($result)中检测$result是否是有效的MySQL结果资源,php,mysql,Php,Mysql,它是用PHP编写的 有时候当我重新启动mysql时 将报告: Debug Warning:line 24 - mysql_fetch_array(): supplied argument is not a valid MySQL result resource 是否有任何方法可以检测$result是否是有效的MySQL结果资源?如果出现错误,它将为false if ($result) { $row = mysql_fetch_array($result); } else { e

它是用PHP编写的

有时候当我重新启动mysql时

将报告:

Debug Warning:line 24 - mysql_fetch_array(): supplied argument is not a valid MySQL result resource

是否有任何方法可以检测$result是否是有效的MySQL结果资源?

如果出现错误,它将为false

if ($result) {
    $row = mysql_fetch_array($result);
} else {
    echo "MySQL error: " . mysql_error();
}
或者你可以这样做:

if ($result) {
      $row = mysql_fetch_array($result);
      // Do everything you need to in here
 }