Forum Moderators: coopster
$fieldstoinsert=array('purchaser', 'orderno', 'contact');
$query = "UPDATE `db`.`formdata` SET `value` = '$fieldstoinsert' WHERE `formdata`.`userid` ='$saveas' AND CONVERT( `formdata`.`value` USING utf8 ) = '$fieldstoinsert' LIMIT 1";
foreach($_POST as $fieldid => $value){
if(in_array($fieldid,$fieldstoinsert)){
if(trim($value)!=""){
$query.="('$value'),";
}
}
}
$query=substr($query,0,-1);
echo $query; //when I echo $query; I get:
UPDATE `db`.`formdata` SET `value` = 'Array' WHERE `formdata`.`userid` ='//tag that matches for user form name//' AND CONVERT( `formdata`.`value` USING utf8 ) = 'Array' LIMIT 1('answer3'),('answer3'),('answer3')
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 '('answer3'),('answer3'),('answer3')' at line 1
Can anyone help me from smacking my head anymore?
There's all kinds of mess going on in there! :)
$fieldtoinsert is an array. That is why the word "Array" is printing in your query statement. What are you expecting the query statement to look like once your code has run and completed building the query statement?