开发者

MySQL INSERT Query [closed]

开发者 https://www.devze.com 2023-01-06 13:23 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

I have probl开发者_如何学Pythonem with my MySQL query:

include '../inc/mysql_config.php';
$sql="INSERT INTO ordrar 
        (id, order, namn, adress, postnummer, postort, email, status)
      VALUES
        (NULL, '$order','$namn','$adress','$postnummer', '$postort', '$email', '$email', '$status')";
 mysql_query($sql);
 if (!mysql_query($sql)) { die('Error: ' . mysql_error()); }

This outputs:

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, namn, adress, postnummer, postort, email, status) VALUES ' at line 1

Thanks.

Solved:

    include '../inc/mysql_config.php';
    $sql="INSERT INTO ordrar (id, substans, namn, adress, postnummer, postort, email, status)
    VALUES
    (NULL, '$substans','$namn','$adress','$postnummer', '$postort', '$email', '$status')";
    mysql_query($sql);
    if (!mysql_query($sql))
      {
      die('Error: ' . mysql_error());
      }

Thanks everyone!


'order' is a reserved word. You'll need to wrap it in backticks, but you'll have less headaches if you rename the column.


I count 8 column names and 9 values. Is '$email' meant to be repeated?

"ORDER" might be a keyword - from ORDER BY SQL. Maybe a quick column name change could fix it. Try it and see.


8 rows, 9 query parameters - you have a duplicate $email variable in the VALUES portion of the INSERT statement.

0

精彩评论

暂无评论...
验证码 换一张
取 消