I try mysql_query() but I get an error saying "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.... the problem is Query String
$val=$_POST["valori"];
$t=explode(",",$val);
$id="";
$nomi="";
$i=0;
$turno=$_POST["turno"];
$div=$_POST["prova"];
$username = "root";
$password = "";
$hostname = "localhost";
$dbname = "culp";
$dbhandle=mysql_connect($hostname, $username, $password);
mysql_select_db($dbname) or die("Unable to select database");
while(count($t)!=$i)
{
$id=$id.$t[$i+1].",";
$nomi=$nomi.$t[$i].",";
$i=$i+2;
}
$query1="INSERT INTO foglio (turno,paper,".$id."data)VALUES('$turno','$div','".$nomi."'CURDATE());";
echo $query1;
mysql_query($query1)or trigger_error(mysql_error()." in ".$query1);