note 6859 modified in mysql_num_rows by ronabop
| From: | ronabop@php.net | Date: | Sat, 19 Aug 2000 04:17:29 +0000 |
| Subject: | note 6859 modified in mysql_num_rows by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-2629@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>
http://www.php.net/manual/function.mysql-num-rows.php