php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26187 mysql_num_rows returns error when empty instead of 0
Submitted: 2003-11-09 19:22 UTC Modified: 2003-11-10 12:53 UTC
From: matt at 1lsn dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.4 OS: Slackware 8.1
Private report: No CVE-ID: None
 [2003-11-09 19:22 UTC] 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' 


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-10 12:53 UTC] iliaa@php.net
var_dump(mysql_num_rows($Result)); will infact return int(0);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Aug 19 19:01:28 2024 UTC