|
Posted by TechieGrl on 08/27/07 19:57
Prepared statements are new to me and having to do this with a multi-
dimensional array is beyond me.
Here is the prepared statement block:
// Prepare to insert a record into table1
$flag_insert = false;
$sql_insert = "INSERT IGNORE INTO table1 ";
$sql_insert .= "(ID, url)";
$sql_insert .= "VALUES ";
$sql_insert .= "($field1, $field2)";
$stmt_insert = $db->stmt_init();
if ($stmt_insert->prepare($sql_insert)){
$flag_insert = true;
}
The array that I want to insert looks like this:
Array (
[0] => Array ( [0] => 1001 [1] => www.google.com )
[1] => Array ( [0] => 1002 [1] => www.yahoo.com )
Here is where I put the 2 together:
// Insert the items into the database
foreach ($rss->items_array as $i){
if($flag_insert){
$stmt_insert->bind_param($sql_insert, 'is', $field1, $field2);
$field1 = $rss->items_array[$i][0];
$field2 = $rss->items_array[$i][1];
echo "sql " . $sql_insert . "\n";
$stmt_insert->execute();
} // if
} // foreach ($ca as $location)
Here is the error:
Fatal error: Cannot pass parameter 2 by reference...
Any thoughts would be so VERY much appreciated!!!
Navigation:
[Reply to this message]
|