php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51400 mysql_fetch_array() returns NULL
Submitted: 2010-03-26 14:56 UTC Modified: 2010-03-26 15:08 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: aa at marcandi dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.3.2 OS: CentOS 5.2 (64-bit)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: aa at marcandi dot com
New email:
PHP Version: OS:

 

 [2010-03-26 14:56 UTC] aa at marcandi dot com
Description:
------------
Calling mysql_fetch_array() with an empty/errorneous result set returns NULL, not 
FALSE. This is a behavioral change from 5.2.10.

Documentation says: "Returns an array of strings that corresponds to the fetched 
row, or FALSE if there are no more rows."


Test script:
---------------
$r = @mysql_query( 'This is a broken query' );
$f = @mysql_fetch_array( $r );
print var_dump( $f );


Expected result:
----------------
FALSE

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-26 15:08 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-03-26 15:08 UTC] johannes@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

The documentation states

  If the parameters given to a function are not what it
  expects, such as passing an array where a string is
  expected, the return value of the function is undefined.
  In this case it will likely return NULL but this is just
  a convention, and cannot be relied upon. 
  http://www.php.net/manual/en/functions.internal.php

You are passing "false" to a function expecting a "mysql result resource"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 13 04:01:26 2024 UTC