Hello, I'm new with PHP. But i hava a error that i can't fix. The response is 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 ''dispatch_case' ('id', 'u_id', 'uur_start', 'dat_start', 'uur_stop', 'type_id', ' at line 1 And the query is: INSERT INTO 'dispatch_case' ('id', 'u_id', 'uur_start', 'dat_start', 'uur_stop', 'type_id', 'post_id', 'subp', 'onderwerp', 'tekst', 'status_id', 'cont-pers-id', 'prio') VALUES ('NULL', 'test', '13:38', '15/04/2011', 'NULL', 'NULL', '1', '2', '', 'test1138', 'test test1136', 'Gesloten', '1', '2'); The source code is: <?php include("inc/inc_connect_mysql.php"); $query="INSERT INTO 'dispatch_case' ('id', 'u_id', 'uur_start', 'dat_start', 'uur_stop', 'type_id', 'post_id', 'subp', 'onderwerp', 'tekst', 'status_id', 'cont-pers-id', 'prio') "; $query .= "VALUES ('"; // let op positie van de enkele aanhalingstekens $query .= 'NULL' ."', '"; $query .= $_POST["u_id"] ."', '" ; $query .= $_POST["uur_start"] ."', '" ; $query .= $_POST["dat_start"] ."', '" ; $query .= 'NULL' ."', '"; $query .= 'NULL' ."', '"; $query .= $_POST["type_id"] ."', '" ; $query .= $_POST["post_id"] ."', '" ; $query .= $_POST["subp"] ."', '" ; $query .= $_POST["onderwerp"] ."', '" ; $query .= $_POST["tekst"] ."', '" ; $query .= $_POST["status_id"] ."', '" ; $query .= $_POST["cont-pers-id"] ."', '" ; $query .= $_POST["prio"] ."');" ; echo($query . '<br>'); $result = mysql_query($query, $db) or die ("Er is een fout opgetreden: " . mysql_error()); echo("De case is ingevoerd en opgeslagen") ; ?> PHP:
Done, new error: INSERT INTO dispatch_case ('id', 'u_id', 'uur_start', 'dat_start', 'uur_stop', 'type_id', 'post_id', 'subp', 'onderwerp', 'tekst', 'status_id', 'cont-pers-id', 'prio') VALUES ('NULL', 'test', '15:54', '15/04/2011', 'NULL', 'NULL', '1', '2', 'mosselbank', 'test1138', 'teste tstsd', 'Open', '1', '2'); Er is een fout opgetreden: 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 ''id', 'u_id', 'uur_start', 'dat_start', 'uur_stop', 'type_id', 'post_id', 'subp'' at line 1 i've already tryed to remove the quotes of the collums, the error is 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 "cont-pers-id', 'prio') VALUES ('NULL', 'test', '15:54', '15/04/2011', 'NU" mvg
Try it in phpMyAdmin. It will show you the mysql code when it does the query and you can compare it with your code.