|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16923 mysql_fetch_object returning incomplete data
Submitted: 2002-04-30 01:28 UTC Modified: 2002-05-01 17:23 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mark at artshouse dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.2.0 OS: slackware 8.0 (modified)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
25 - 18 = ?
Subscribe to this entry?

 [2002-04-30 01:28 UTC] mark at artshouse dot com
This was found in an ongoing project I am upgrading from php 4.0.4pl1

code sample:

$sql='select prodId, prodNum from products';
$result = mysql_query($sql);

do {
print $product->prodId ." ". $product-prodNum
} while ($product = mysql_fetch_object($result));

print_r ($product) returns:
stdClass Object ( [prodId] => [prodNum] => E-U-00-002)
stdClass Object ( [prodId] => [prodNum] => E-U-00-003)
stdClass Object ( [prodId] => [prodNum] => E-U-00-004)

the real data would be prodId => 1, prodId => 2

the same thing done with mysql_fetch_array works perfectly (exact same sql, etc) 

I tried various loops (do..while, if, while) no changes.

Tested this with php 4.1.2 and 4.2.0 w/ same errors.  Works fine on 4.0.4pl1.

php configure options as follows:

'./configure' \
'--with-mysql=/usr/local' \
'--enable-track-vars' \
'--with-dbase' \
'--with-gd=/usr/local/gd-1.8.4' \
'--with-ttf' \
'--with-t1lib' \
'--with-jpeg-dir' \
'--with-png-dir' \
'--with-tiff-dir' \
'--with-apxs=/usr/local/apache/bin/apxs' \
'--with-config-file-path=/usr/local/apache/conf' \
'--with-pdflib' \
'--enable-ftp' \

I am unable to provide a backtrace (production server, sorry)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-01 17:21 UTC] mark at artshouse dot com
I finally tracked this down... it was a bad sql call on my 
part (sort of) and a change in behaviour in 

I did a call like "select * from products left join details 
on products.prodId=details.prodId"

which returns 2 different prodId (one from each 
table)....because of the join and the fact the details 
doesn't always include prodId (i.e. if there is not a 
matching join) the second prodId was NULL

in php 4.0.4pl1 mysql_fetch_object still set a valid prodId 
for everything ( I am assuming it ignored the NULL 
value) php 4.0.6 and newer it sets it to the last 
value it got for prodId (again assuming) which is sometimes 
NULL, sometimes a good value

not sure whether this should be a bug or not.  Anyone?

 [2002-05-01 17:23 UTC] mark at artshouse dot com
Can someone check to see if this needs attention or not?
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 25 01:01:28 2024 UTC