$con = mysql_connect($server, $user, $password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($user, $con);
$ref='444';
$name="x7";
$quant =1;
$price=7000;
$sql= "INSERT INTO order(ref_id, name, quantity, price, status) VALUES ('$ref','$name','$quant','$price','pending')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
This code is in php block. when i execute it i get this:
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 'order(ref_id, name, quantity, price, status) VALUES ('444','x7','1','7000','pend' at line 1
So any idea where i am going wrong? When I read the content of the table, it works fine thus proving that the connection and db is working fine. I am getting this problem whenever I try to populate a table. I am a Newbie in php and mysql :(. Please excuse me if the code contain a very silly mistake of mine :)