Try doing
echo $sql;
to see if the sql is generating the way it should. If not, you can try
$sql="INSERT INTO ".$tbl_name."(name, lastname, email)VALUES('".$name."', '".$lastname."', '".$email."')";
If the sql seems right, try copying it and running it on sql mannager to see if you get an error. Aparently it's an error from your sql server and not php so try that.