From:             fala at gmx dot net
Operating system: Debian_2
PHP version:      5.1.4
PHP Bug Type:     MySQLi related
Bug description:  mysqli prepared statement fetch() bug

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 bug report at http://bugs.php.net/?id=37884&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37884&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=37884&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37884&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37884&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37884&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37884&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37884&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37884&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37884&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37884&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37884&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37884&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37884&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37884&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37884&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37884&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37884&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37884&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37884&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37884&r=mysqlcfg

Reply via email to