Hi guys,
I have this sql statement that is trying to insert data from some fields
<?php
$con = mysql_connect("xxx","xx","xx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxx", $con);
$sql="INSERT INTO guests (guest_name, guest_email) VALUES";
for($i=0;$i<sizeof($_POST);$i++){
$sql.="('".mysql_real_escape_string($_POST[$i])."','".mysql_real_escape_string($_POST[$i])."')";
if(!$i==sizeof($_POST)){
$sql.=",";
}
}
//
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "record added";
?>
but it returns the error
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 '' at line 1