Hello all. I wrote this function to allow me to mass update a table by means of two arrays combining and running a query. I get this odd error message. Could someone help me out please?
Here is the code I am using first.
Be advised that this is in a class called dbConnection
function arr_update($t, $a, $b, $c, $d){
if(count($a) !== count($b))
return false;
$i = 0;
foreach($a as $a){
$a[$i] .= "='".$b[$i]."'";
$i++;
}
$sql = "UPDATE ".$t." SET ".implode(", ", $a)." WHERE ".$c."='".$d."'";
echo $sql;
/*if($this->query($sql))
return true;
else
return false;*/
}//end arr_insert
Here is the error message
Fatal error: Cannot use assign-op operators with overloaded objects nor string offsets in /home/xxxxxx/public_html/xxxxxxx/xxxxxxx.inc.php on line 129
Here is how I call it...sorry, it is kinda long...
$t = "stock_autos";
$now = $db->results("SELECT NOW()");
$a = array("uid", "vin", "cat", "year", "make", "model",
"edition", "engine", "fueltype", "trans", "miles",
"bodystyle", "drivetrain", "doors", "inttype", "intcolor",
"extcolor", "stockid", "cond", "features", "details",
"price", "sale", "sale_price", "active",
"edited", "location");
$b = array($uid, $vin, $cat, $year, $make, $model, $edition,
$engine, $ftype, $trans, $miles, $bstyle, $dtrain,
$doors, $inttype, $intcolor, $extcolor, $stockid,
$cond, $features, $details, $price, $osale, $saleprice,
$active, $now, $location);
$c = "uid";
$d = $uid;
if($db->arr_update($t, $a, $b, $c, $d)){
echo 'Congradulations! The listing was successfully updated!';
echo '<br><br>Would you like to upload images and associate them with this listing?<br><br>';
echo $box->linkbox("Yes, I would", "admin_inv_imgs.php?i=".$uid);
echo " ";
echo $box->linkbox("No, not yet", "admin_index.php");
} else
echo 'Could not update the listing.<br>Check the error log.';
:bemused: