#26187 [NEW]: mysql_num_rows returns error when empty instead of 0
| From: | matt at 1lsn dot com | Date: | Mon, 10 Nov 2003 00:22:58 +0000 |
| Subject: | #26187 [NEW]: mysql_num_rows returns error when empty instead of 0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-50186@lists.php.net to get a copy of this message | ||
From: matt at 1lsn dot com
Operating system: Slackware 8.1
PHP version: 4.3.4
PHP Bug Type: MySQL related
Bug description: mysql_num_rows returns error when empty instead of 0
Description:
------------
when doing a mysql_num_rows, if there are no matching rows it gives an
error instead of returning 0.
Reproduce code:
---------------
$Query = "SELECT * FROM MyTable WHERE Field1 = '1' and Field2 = '2' ";
$Result = mysql_query($Query) or die("Error101: ".
mysql_error()."<BR>".$Query);
$CNT = mysql_num_rows($Result) OR DIE("Error 102:
"."<BR>".mysql_error()."<BR>".$Query."<BR>");
echo "There are ".$CNT." matching results. ";
Expected result:
----------------
$CNT should be set to '0' and page should display
"There are 0 matching results."
Actual result:
--------------
Error 102:
SELECT * FROM MyTable WHERE Field1 = '1' and Field2 = '2'
--
Edit bug report at http://bugs.php.net/?id=26187&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26187&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26187&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26187&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26187&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26187&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=26187&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26187&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26187&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26187&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26187&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26187&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26187&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26187&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26187&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26187&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26187&r=float