简体   繁体   中英

how to detect $result is a valid MySQL result resource in mysql_fetch_array($result)

It's written in PHP,

and sometimes when I restart mysql,

will report:

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

Is there any way to detect if $result is a valid MySQL result resource?

it'll be false if there's an error.

if ($result) {
    $row = mysql_fetch_array($result);
} else {
    echo "MySQL error: " . mysql_error();
}

Or you could just do:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM