#25627 [Bgs]: mysql_fetch_array (); returns NULL on connection/querie failure
| From: | MDonatas at centras dot lt | Date: | Tue, 23 Sep 2003 08:06:35 +0000 |
| Subject: | #25627 [Bgs]: mysql_fetch_array (); returns NULL on connection/querie failure | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-47974@lists.php.net to get a copy of this message | ||
ID: 25627
User updated by: MDonatas at centras dot lt
Reported By: MDonatas at centras dot lt
Status: Bogus
Bug Type: MySQL related
Operating System: Windows XP
PHP Version: 4.3.3
New Comment:
Thank you for your fast reply.
I've checked the manual once again but I still couldn't find anything
about NULL being returned. So either the manual needs updating or the
function, which would solve some missunderstandings.
Previous Comments:
------------------------------------------------------------------------
[2003-09-22 18:52:38] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You are supposed to provide correct arguments to the function. If they
query has failed you should return value then, not pass it to another
function.
------------------------------------------------------------------------
[2003-09-22 09:00:56] MDonatas at centras dot lt
Description:
------------
In documentation for mysql_fetch_array (); it says "Returns an array
that corresponds to the fetched row, or FALSE if there are no more
rows."
But if connection to database fails or querie is somewhat wrong, this
function will return NULL which is defenitely wrong.
if you have script like
while (FALSE !== ($info = mysql_fetch_array ($result)))
{
...
}
then it will start infinite loop.
Reproduce code:
---------------
<?
//WARNING! This will start infinite loop
while (FALSE !== ($info = mysql_fetch_array ($result)))
{
}
?>
Expected result:
----------------
Should return FALSE on any failures
Actual result:
--------------
Returns NULL on failures.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25627&edit=1