note 111554 added to mysqli-stmt.bind-param
| From: | Ray.PaseurusesGmail | Date: | Sun, 03 Mar 2013 17:24:07 +0000 |
| Subject: | note 111554 added to mysqli-stmt.bind-param | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193787@lists.php.net to get a copy of this message | ||
It may seem obvious, but it's worth noting that variables must exist before you can bind them.
This example worked well for me (line 12).
<?php
$test_names_arrays = array
( array( "fname" => "Walter" , "lname" => "Williams" )
, array( "fname" => "Ray" , "lname" => "Paseur" )
, array( "fname" => "Bill" , "lname" =>
"O'Reilly" )
)
;
$sql = "INSERT INTO my_table ( fname, lname ) VALUES ( ?,? )";
$ins = $mysqli->prepare($sql);
// NB: THESE VARIABLES MUST EXIST BEFORE THEY CAN BE BOUND!
$person = current($test_names_arrays);
$ins->bind_param('ss', $person['fname'], $person['lname']);
foreach ($test_names_arrays as $person)
{
$ins->execute();
}
----
Server IP: 69.147.83.199
Probable Submitter: 98.169.50.31
----
Manual Page -- http://php.net/manual/en/mysqli-stmt.bind-param.php
Edit -- https://master.php.net/note/edit/111554
Del: integrated -- https://master.php.net/note/delete/111554/integrated
Del: useless -- https://master.php.net/note/delete/111554/useless
Del: bad code -- https://master.php.net/note/delete/111554/bad+code
Del: spam -- https://master.php.net/note/delete/111554/spam
Del: non-english -- https://master.php.net/note/delete/111554/non-english
Del: in docs -- https://master.php.net/note/delete/111554/in+docs
Del: other reasons-- https://master.php.net/note/delete/111554
Reject -- https://master.php.net/note/reject/111554
Search -- https://master.php.net/manage/user-notes.php