From: evangun2001 at yahoo dot fr Operating system: windows PHP version: 5CVS-2007-09-17 (CVS) PHP Bug Type: MySQLi related Bug description: Cannot bind parameter to a dimensional value within a foreach loop
Description: ------------ Hello, As you can see in the code below, binding to $value['id'] will not work because $value is a variable generated by the foreach loop. Using a dimensional variable as a parameter causes no bugs outside a foreach loop, so I'm pretty sure it really is a bug. $arr = array(array('id' => 1)); $stmt = $dbh -> prepare('SELECT member_login FROM members WHERE member_id = ?;'); $stmt -> bind_param('i', $value['id']); foreach($arr as $value){ echo $value['id']; //this will output 1 as expected $stmt -> execute(); $stmt -> bind_result($login); while($stmt -> fetch()){ echo $login; //this will output nothing } } Reproduce code: --------------- The code I've given in description pretty much says it all ! For a quick and global understanding of the situation, I've also put a summary of what works, what does not work, and the workaround I've been using so far. Check it here : http://trombiaudencia2.free.fr/bug.txt Actual result: -------------- Just to let you know, in my application, the real bind_param line looked like : $stmt -> bind_param('si', $_POST['members'][$value['id']]['login'], $value['id']); and in that case, php told me : Fatal error: Only variables can be passed by reference in E:\Program Files\EasyPHP\www\create_quiz_ajaxrequests.php on line 368 which is due to the second parameter, the first one does not create any warning at all. Strange, because you'll see that in the simplified example I've given above, no error message is displayed at all. I use loops all the time so to me, it's reeaaally a down side for MySQLi not to be able to bind parameters. I have been using PDO for a while and heard MySQLi had better performances, but this kinda cools me down :( Maybe I'll wait a bit until this bug is fixed before I migrate to MySQLi. Thank you very much !! Evangun -- Edit bug report at http://bugs.php.net/?id=42689&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42689&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42689&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42689&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42689&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42689&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42689&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42689&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42689&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42689&r=support Expected behavior: http://bugs.php.net/fix.php?id=42689&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42689&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42689&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42689&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42689&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42689&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42689&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42689&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42689&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42689&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42689&r=mysqlcfg