语法错误查询INSERT INTO php

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); 

I assume you are inserting four values in your query. So you should write:

$query1="INSERT INTO foglio (turno,paper,$id,data)VALUES('$turno','$div','$nomi',CURDATE());";

You are wrapping the query in double quotes so you don't need the single ones. You were missing a comma between the third and the fourth item in the query

Also I assume you are just doing this for a personal project because you are using a deprecated api (mysql_*) that will be removed in the next php release (so your code will not work anymore). Also your code is open to sql injections and you should move to prepared statements