PHP数据库相关的错误,以及MySQL错误

时间:2013-04-14 18:00:59

标签: php mysql

这是我在进一步输入代码时收到的错误:

  

您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在'order(order_date,cust_firstname,cust_lastname,cust_add,cust_city,cust_state,indi')第1行附近使用正确的语法

此错误的代码是:

<?php
include "db.php";
    $cust_firstname=$_POST['name'];
    $cust_lastname=$_POST['lastname'];
    $cust_add=$_POST['add'];
    $cust_city=$_POST['city'];
    $cust_state=$_POST['state'];
    $cust_country=$_POST['country'];
    $cust_zip=$_POST['pincode'];
    $cust_phone=$_POST['mobile'];
    $cust_email=$_POST['email'];
    $sql=mysql_query("INSERT INTO order(order_date,cust_firstname,cust_lastname,cust_add,cust_city,cust_state,$cust_country,cust_zip,cust_phone,cust_email)values(now(),'$cust_firstname','$cust_lastname','$cust_add','$cust_city','$cust_state','$cust_country','$cust_zip','$cust_phone','$cust_email')")or die(mysql_error());
    header("location:done.php");
?>

我想知道的是,这个错误究竟意味着什么以及我需要做些什么来解决它?

2 个答案:

答案 0 :(得分:1)

订单是reserved keyword。你需要将它包装在刻度线中:

$sql=mysql_query("INSERT INTO `order` (order_date,

答案 1 :(得分:0)

试试这个

    $sql=mysql_query("INSERT INTO `order` (order_date,cu.....

order是mysql中保留的关键字

编辑:

更改此

   $cust_country

   cust_country

在插入参数列