Kasun Kumara Kasun Kumara - 1 year ago 70
PHP Question

check the manual that corresponds to version for the right syntax to use near 'order(NIC,DorP,Address,Time) VALUES ('933560657V','on',


$nic = $_POST["NIC"];
$dp = $_POST["DP"];
$address = $_POST["Address"];
$time = $_POST["DPTime"];
$tele = $_POST["Tele"];
$mail = $_POST["Email"];

$sql="INSERT INTO order (NIC,DP,Address,DPTime,Telephone,Email) VALUES ('$nic ','$dp', '$address','$time','$tele','$mail')";

$result = mysqli_query($db,$sql);

if (!$result)
echo "Order not properly place! Please place again!";
echo "Order placed successfully ";


My "mysqli_query()" does not work properly though a connection is established successfully by the mysqli_connect() which is in the db.php file.Please help me to rectify this problem.

Answer Source

Order is a reserved word in MySQL. You need to put it into backticks.

   INSERT INTO `order`
   VALUES ('$nic ','$dp', '$address','$time','$tele','$mail')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download