From:             oliver dot klink at volksbank-rems dot de
Operating system: Windows Server 2003
PHP version:      5.2.0
PHP Bug Type:     MySQLi related
Bug description:  bind_param / explode not updating an array as parameters

Description:
------------
I try to use mysqli_stmt_bind_param with several elements of an array as
parameters. But it seems that these parameters are not updated properly.
In the sample code I initialize the var $data with two values. Otherwise I
would get an error saying that the column is not allowed to be null, when I
execute the statement.
These start values should be overwritten by the values generated by the
explode function. print_r shows that the array $data gets updated as
expected while the values transmitted by mysqli_stmt_execute are not.
If I place the mysqli_stmt_bind_param after the explode-command the script
works as expected, but I think that's not how mysqli_stmt_bind_param is
meant to be used.

Reproduce code:
---------------
<?php
$dw = new mysqli("localhost", "****", "****", "testdb");
$dw->query("CREATE TABLE IF NOT EXISTS `test` (
                `filiale` smallint(5) unsigned NOT NULL,
                `berater` smallint(5) unsigned NOT NULL,
                PRIMARY KEY (`filiale`)
        )");

$data = array(1,2);
$test = array("10;123","20;456");

$stmt = $dw->prepare("INSERT INTO test (filiale, berater) VALUES (?,?)");
$stmt->bind_param("ii",$data[0],$data[1]);

foreach ($test as $buffer) {
        
        $data = explode(";", $buffer);
        print_r($data);

        $stmt->execute();
        echo $dw->error."<br>&nbsp;<br>";
}
$stmt = null;
$dw = null;
?>

Expected result:
----------------
Array ( [0] => 10 [1] => 123 )
 
Array ( [0] => 20 [1] => 456 )

Actual result:
--------------
Array ( [0] => 10 [1] => 123 )
 
Array ( [0] => 20 [1] => 456 ) Duplicate entry '1' for key 1

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

Reply via email to