ID:               40154
 Updated by:       [EMAIL PROTECTED]
 Reported By:      oliver dot klink at volksbank-rems dot de
-Status:           Open
+Status:           Assigned
 Bug Type:         MySQLi related
 Operating System: Windows Server 2003
 PHP Version:      5.2.0
-Assigned To:      
+Assigned To:      georg


Previous Comments:
------------------------------------------------------------------------

[2007-01-17 14:32:26] oliver dot klink at volksbank-rems dot de

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 this bug report at http://bugs.php.net/?id=40154&edit=1

Reply via email to