Php 如何在MySQL\u fetch\u数组($result)中检测$result是否是有效的MySQL结果资源
它是用PHP编写的 有时候当我重新启动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
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
}