php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32405 mysqli->fetch() is returning bad data
Submitted: 2005-03-22 00:06 UTC Modified: 2005-04-19 15:45 UTC
From: paul at thehedron dot com Assigned: georg (profile)
Status: Closed Package: MySQLi related
PHP Version: 5CVS-STABLE-2005-03-24 OS: Linux (fedora core 3)
Private report: No CVE-ID: None
 [2005-03-22 00:06 UTC] paul at thehedron dot com
Description:
------------
mysqli->fetch() is returning bad data on int columns.  I saw this listed, then closed as bogus (29002).  I just hit it today and assure you it is not bogus.  

Here is my full setup:
-----------------------------------------------------------
CPU: AMD64 
OS:  Fedora Core 3 (2.6.9-1.667)
PHP: 5.0.3
     libmcrypt-2.5.7
     mcrypt-2.6.4
     mhash-0.9.2
Apache: 1.3.33
     mod_ssl-2.8.22-1.3.33
     openssl-0.9.7e
MySQL: 4.1.10
GCC: 3.4.2
-----------------------------------------------------------
PHP configuration:
./configure \
--with-apxs=/www/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mcrypt=/shared/LAMP/PHP5/libmcrypt-2.5.7 \
--enable-ftp \
--enable-trans-sid 


Reproduce code:
---------------
CREATE TABLE users (
user_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
lastname VARCHAR(50) NOT NULL,
PRIMARY KEY(user_id));
-----------------------------------------------------------------------
<?php
$mysqli = new mysqli('localhost', 'user', 'password', 'test');

if ($stmt = $mysqli->prepare("SELECT user_id, lastname FROM users")) {
   $stmt->execute();

   $stmt->bind_result($col1, $col2);

   while ($stmt->fetch()) {
       printf("%s %s <br />", $col1, $col2);
   }
   $stmt->close();
}
$mysqli->close();
?> 


Expected result:
----------------
Expected results:
1 Peterson
2 Asenbach

Actual result:
--------------
Actual results:
32199691940659210 Peterson 
32199691940659211 Asenbach 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-22 20:20 UTC] paul at thehedron dot com
Pulled down the recommended CVS snapshot, compiled and installed.  Info shows PHP Version 5.0.4RC2-dev.

Ran the same code and got the same result.
 [2005-03-23 23:48 UTC] sniper@php.net
Georg, there are several reports open on mysqli already..can you finally fix the stuff or move the whole thing to sibe..PECL?

 [2005-03-29 11:47 UTC] georg@php.net
Can't repeat (user gave me access on this machine):

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> CREATE TABLE users (
    -> user_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    -> lastname VARCHAR(50) NOT NULL,
    -> PRIMARY KEY(user_id));
Query OK, 0 rows affected (0.02 sec)

mysql> insert into users value (0, 'Paul'), (0, 'Georg');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> quit

[georg@ascdev ~]$ cat 32405.php
<?php
$mysqli = new mysqli('localhost', 'georg', '', 'test');

if ($stmt = $mysqli->prepare("SELECT user_id, lastname FROM users")) {
   $stmt->execute();

   $stmt->bind_result($col1, $col2);

   while ($stmt->fetch()) {
       printf("%s %s\n", $col1, $col2);
   }
   $stmt->close();
}
$mysqli->close();
?>

[georg@ascdev ~]$ php -f 32405.php
1 Paul
2 Georg
 [2005-03-30 09:32 UTC] georg@php.net
Update: The bug only occurs when connecting via TCP/IP - it's a protocol problem in MySQL (but not a PHP problem).

I will analyze it and file a bug report on bugs.mysql.com
 [2005-04-19 15:45 UTC] andrey@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Thanks for support for fixing this bug on 64 bit platform. It is also fixed in the 5_0 branch.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC