I'm trying to upload multiple columns at once with this code:
function updateMultiple($idElement,$arrayFieldValues=""){
$toSave=$arrayFieldValues?$arrayFieldValues:$_POST;
foreach($toSave as $field => $value) {
if (strpos($field, 'save_') === 0) {
$field = str_replace('save_', '', $field);
$updateString .= $field."='".addslashes($value)."', ";
}
}
$updateString = substr_replace($updateString ,"",-2);
$query="UPDATE ".$this->tab."
SET ".$updateString.", lastUser='".$usrId."'
WHERE ".$colName." = '".$idElement."'";
$this->execute($query);
}
However I get this error:
PDOStatement::execute() [pdostatement.execute]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET Country='England', FirstName='John', LastName='Smith', lastUser='10' ' at line 2
But to me it all seems right!