#37884 [Opn->Fbk]: mysqli prepared statement fetch() bug
| From: | tony2001@php.net | Date: | Mon, 26 Jun 2006 13:54:04 +0000 |
| Subject: | #37884 [Opn->Fbk]: mysqli prepared statement fetch() bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-98786@lists.php.net to get a copy of this message | ||
ID: 37884
Updated by: tony2001@php.net
Reported By: fala at gmx dot net
-Status: Open
+Status: Feedback
Bug Type: MySQLi related
Operating System: Debian_2
PHP Version: 5.1.4
Assigned To: andrey
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2006-06-26 13:33:01] 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-22 18:55:52] 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-22 17:07:55] 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 16:45:19] 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 11:31:32] 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"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37884&edit=1