Jump to content

cant add to database.. pliz help.


lesolemph

Recommended Posts

<?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

Link to comment
https://forums.phpfreaks.com/topic/183677-cant-add-to-database-pliz-help/
Share on other sites

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.