I'm running a wamp server and created a series of html webpages the data being put in by the user is then being submitted to a SQL database through a PHP script. I created a database table with Id. set to INT auto increment Crime. and Suspect. set as VARCHAR(40)
. I can connect to the database but now when I try to insert I get the error:
'Problem with insert: 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 'case (Id, Case, Suspect) VALUES('NULL', 'test', 'test12')' at line 1'
So I know its an issue with the insert function however cannot fix it!
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$db = 'fid';
$case = (isset($_POST['case'])? $_POST['case']:"None");
$suspect= (isset($_POST['suspect'])? $_POST['suspect']:"None");
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$conn)
die('Could not connect: ' . mysql_error());
mysql_select_db($db);
mysql_query("INSERT INTO case
(Id, Case, Suspect) VALUES('NULL', '$case', '$suspect') ")
or die(' Problem with insert: ' . mysql_error());
echo 'Connected successfully';
mysql_close($conn);
?>