#26187 [Opn->Bgs]: mysql_num_rows returns error when empty instead of 0
| From: | iliaa@php.net | Date: | Mon, 10 Nov 2003 17:53:29 +0000 |
| Subject: | #26187 [Opn->Bgs]: mysql_num_rows returns error when empty instead of 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-50203@lists.php.net to get a copy of this message | ||
ID: 26187
Updated by: iliaa@php.net
Reported By: matt at 1lsn dot com
-Status: Open
+Status: Bogus
Bug Type: MySQL related
Operating System: Slackware 8.1
PHP Version: 4.3.4
New Comment:
var_dump(mysql_num_rows($Result)); will infact return int(0);
Previous Comments:
------------------------------------------------------------------------
[2003-11-09 19:22:58] matt at 1lsn dot com
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 this bug report at http://bugs.php.net/?id=26187&edit=1