|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
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"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.