lesolemph Posted December 2, 2009 Share Posted December 2, 2009 <?php //starting the session session_start(); include("dbconnector.php"); $tbl_name="database"; $machineCode = $_POST['machineCode']; $machineLocation = $_POST['station']; $calibrationDate = $_POST['calibrationDate']; $calibrationDueDate = $_POST['calibrationDueDate']; $nextCalibrationDate = $_POST['nextCalibrationDate']; $submitMachine = $_POST['submitMachine']; $sql="INSERT INTO $tbl_name(machineCode, machineLocation, calibrationDate, calibrationDueDate, nextCalibrationDate, submitMachine)VALUES('$machineCode', '$machineLocation', '$calibrationDate', '$calibrationDueDate', '$nextCalibrationDate', '$submitMachine')"; $result=mysql_query($sql); if($result){ echo "inserted"; } else{ die('Error: ' . mysql_error()); } mysql_close($con); ?> i get the following error evrytym when i try to add data to the database; Error: 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 'database(machineCode, machineLocation, calibrationDate, calibrationDueDate, next' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/183677-cant-add-to-database-pliz-help/ Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 database is a reserved keyword, this should work $sql="INSERT INTO `$tbl_name` (machineCode, machineLocation, calibrationDate, calibrationDueDate, nextCalibrationDate, submitMachine)VALUES('$machineCode', '$machineLocation', '$calibrationDate', '$calibrationDueDate', '$nextCalibrationDate', '$submitMachine')"; Quote Link to comment https://forums.phpfreaks.com/topic/183677-cant-add-to-database-pliz-help/#findComment-969476 Share on other sites More sharing options...
lesolemph Posted December 2, 2009 Author Share Posted December 2, 2009 thanks it worked Quote Link to comment https://forums.phpfreaks.com/topic/183677-cant-add-to-database-pliz-help/#findComment-969533 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.