note 111554 deleted from mysqli-stmt.bind-param by cmb

From: Date: Sun, 22 Sep 2019 08:05:59 +0000
Subject: note 111554 deleted from mysqli-stmt.bind-param by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212314@lists.php.net to get a copy of this message
Note Submitter: Ray.Paseur uses Gmail ---- 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(); } ?>

« previous php.notes (#212314) next »