note 6859 deleted from mysql_num_rows by danbeck
| From: | danbeck@php.net | Date: | Thu, 07 Sep 2000 17:09:59 +0000 |
| Subject: | note 6859 deleted from mysql_num_rows by danbeck | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-4408@lists.php.net to get a copy of this message | ||
If you get:
"Warning: Supplied argument is not a valid MySQL result resource in /path/to/file.php on line
XX "
This warning-message only occurs when there are no rows matching a query (or when an insert or
update query is used).
With php3 the value result-identifier in such case would be <= 2, but with php4 it's now
called Resource id #2. So, with an ereg() or split() it should be possible to get the number. Then
you can make something like:
<pre>
$qID = mysql_query('SELECT xxx');
$arr = split('#', $qID);
$num_rows = 0;
if ($this->errno() == 0 && $arr[1] >= 2)
$num_rows = mysql_num_rows($qID);
</pre>