PDA

View Full Version : where wrong


xiaodao
04-29-2005, 02:11 PM
if($_REQUEST['action']=="addcontact"){
foreach($HTTP_POST_VARS AS $k=>$v){
if($k!=="submit"){
$ks[]=$k;
$vs[]=$v;
}
}

$keyz=implode(",",$ks);
$valz=implode(",",$vs);
$str="";
$num=count($vs);
$num1=$num-1;
for($i=0;$i<($num1);$i++){
$str.="'";
$str.=$vs[$i];
$str.="',";
}
$str.="'";
$str.=$vs[$num1];
$str.="'";
$query="INSERT INTO TABLE `pa_contact` ($keyz) VALUES ($str)";
$sql=$db->query($query);
if(!$sql){
msg("Error Message",mysql_error());
}else{
redirect("addcontact.php");
msg("Successful","The data is successfully entered");
}
}

xiaodao
04-29-2005, 02:11 PM
after testing, it become like this
Mysql error 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 'TABLE `pa_contact` (lov,gogo,haha,test2,test1) VALUES ('it','b',

marek_mar
04-29-2005, 04:09 PM
You might want to read how to use INSERT (http://dev.mysql.com/doc/mysql/en/insert.html)...