Kasun Kumara Kasun Kumara - 3 months ago 15
PHP Question

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

require("includes/db.php");

$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!";
}
else
{
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

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

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