php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37884 mysqli prepared statement fetch() bug
Submitted: 2006-06-22 11:31 UTC Modified: 2006-07-13 01:00 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: fala at gmx dot net Assigned: andrey (profile)
Status: No Feedback Package: MySQLi related
PHP Version: 5.1.4 OS: Debian_2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-06-22 11:31 UTC] fala at gmx dot net
Description:
------------
MySQLi prepared statement fetch() returns incorrect values and binds them in the incorrect order. Code works with PHP 5.0.3, but not with 5.1.4 (5.1.2 was also tested and erronous as well).

The following code shows a sample DB Setup with MySQL 5.0.22 on a Debian System, and the fetch statement that causes the bug.

Reproduce code:
---------------
CREATE TABLE `foo` (
  `ID` int(11) NOT NULL auto_increment,
  `value_f_1` float NOT NULL default '0',
  `value_f_2` float NOT NULL default '0',
  `value_f_3` float NOT NULL default '0',
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=97 ;

INSERT INTO `foo` VALUES (64, 2, 0.85, 1);


-------


$sql = 'SELECT ID, value_f_1, value_f_2, value_f_3
FROM foo
WHERE ID = ?';

$stmt = $db->prepare( $sql ) OR die('...');
$stmt->bind_param( 'i', 64 );
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($ID, $value_f_1, $value_f_2, $value_f_3);
$stmt->fetch();

echo 'ID: "'.$ID.'", V1: "'.$value_f_1.'", V2: "'.$value_f_2.'", V3: "'.$value_f_3.'"';

Expected result:
----------------
(Output with PHP 5.0.3)
ID: "64", V1: "2", V2: "0.850000023842", V3: "1"

Actual result:
--------------
(Output with PHP 5.1.4)
ID: "64", V1: "4.4847901283E-34", V3: "2", V3: "0.850000023842"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-22 16:45 UTC] andrey@php.net
 Hi,
I wasn't able to reproduce.
Could you add the following to your script and give the output :
var_dump("Client",mysqli_get_client_version(), "Server", mysqli_get_server_version());
Thanks


andrey@lmy004:~/dev/5_0> sapi/cli/php /tmp/a.php
string(9) "5.0.6-dev"
ID: "64", V1: "2", V2: "0.85000002384186", V3: "1"

andrey@lmy004:~/dev/5_1> sapi/cli/php /tmp/a.php
string(9) "5.1.5-dev"
ID: "64", V1: "2", V2: "0.85000002384186", V3: "1"

andrey@lmy004:~/dev/5_2> sapi/cli/php /tmp/a.php
string(9) "5.2.0-dev"
ID: "64", V1: "2", V2: "0.85000002384186", V3: "1"

andrey@lmy004:~/dev/6_0> sapi/cli/php /tmp/a.php
string(9) "6.0.0-dev"
ID: "64", V1: "2", V2: "0.85000002384186", V3: "1"

 [2006-06-22 17:07 UTC] fala at gmx dot net
var_dump("Client",mysqli_get_client_version(), "Server",
mysqli_get_server_version());

->
string(6) "Client" int(50022) string(6) "Server" int(50022)

Our Server Admin changed the PHP Version to 5.0.4, but the Bug still occurs.
 [2006-06-22 18:55 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-06-26 13:33 UTC] fala at gmx dot net
Sorry, but my Web-Admin doesn't want to upgrade to a daily snapshot for security reasons... Did you fix anything and wanted me to verify the fix? Or did you just want me to try and see if the bug occurs in the newest version?
 [2006-06-26 13:54 UTC] tony2001@php.net
Your admin doesn't have to upgrade anything.
You cam build the snapshot in your own home directory and test it without affecting whole system.
 [2006-07-04 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-07-05 18:57 UTC] fala at gmx dot net
It's a dedicated server and we only have 1 php version in the system. My admin won't upgrade to a daily snapshot due to security reasons... He will only change to a release version...

Could you replicate the bug? Did you find and change anything that might have caused the problem?
 [2006-07-05 19:24 UTC] tony2001@php.net
No, I can't reproduce it.
And I repeat it: you don't need to touch anything on your server. In fact, you even don't need to ask your admin if you have an account there - just build the snapshot in your home dir.
 [2006-07-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Aug 13 09:05:44 2022 UTC