ID: 42689 User updated by: evangun2001 at yahoo dot fr Reported By: evangun2001 at yahoo dot fr Status: Open Bug Type: MySQLi related Operating System: windows PHP Version: 5CVS-2007-09-17 (CVS) New Comment:
Hello, I've run the tests on 5.2.0, 5.2.4 and CVS, MySQL 5.0.27. Same results each time. By the way, just to let you know, the CVS version seems unstable with my full MySQLi script (more complex than what I've shown you), whereas it works with 5.2.4. Thanks Previous Comments: ------------------------------------------------------------------------ [2007-09-19 11:04:09] uwendel at mysql dot com Can you tell me what MySQL and PHP versions you're using? Is it really a CVS version/development snapshot that you're using? Thanks! Ulf ------------------------------------------------------------------------ [2007-09-17 22:26:39] evangun2001 at yahoo dot fr 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 this bug report at http://bugs.php.net/?id=42689&edit=1