Bug #60251 [NEW]: mysql_fetch_row bad return value on error

From: Date: Wed, 09 Nov 2011 15:03:30 +0000
Subject: Bug #60251 [NEW]: mysql_fetch_row bad return value on error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-164993@lists.php.net to get a copy of this message
From:             
Operating system: Windows
PHP version:      5.3.8
Package:          MySQL related
Bug Type:         Bug
Bug description:mysql_fetch_row bad return value on error

Description:
------------
When $result parameter of mysql_fetch_row isn't resource, mysql_fetch_row
returns NULL instead of FALSE.

This code:

while (($data = mysql_fetch_row($result)) !== false) {
   ...
}

gets in infinite loop

Test script:
---------------
$result = mysql_query("BAD SQL SYNTAX OR CONNECTION PROBLEM"); 
// $result value is now FALSE

$data = mysql_fetch_row($result);
var_dump($data);

Expected result:
----------------
bool(false)

Actual result:
--------------
NULL

-- 
Edit bug report at https://bugs.php.net/bug.php?id=60251&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=60251&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=60251&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=60251&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=60251&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60251&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=60251&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=60251&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=60251&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=60251&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=60251&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=60251&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=60251&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=60251&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=60251&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=60251&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60251&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=60251&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=60251&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=60251&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=60251&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=60251&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#164993) next »