Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php SQL不喜欢十进制_Php_Mysql - Fatal编程技术网

Php SQL不喜欢十进制

Php SQL不喜欢十进制,php,mysql,Php,Mysql,我正在尝试将一条新记录插入表“order”。代码如下: $orderDB = mysql_query("INSERT INTO order (itemsID, deliveryDestinationID, total, shipped) VALUES ($itemID, $delivery, $totalprice, 'N')") or die(mysql_error()); 变量为$itemID(5位数字),$delivery(5位数字),$totalprice(交易成本),例如137.97

我正在尝试将一条新记录插入表“order”。代码如下:

$orderDB = mysql_query("INSERT INTO order (itemsID, deliveryDestinationID, total, shipped) VALUES ($itemID, $delivery, $totalprice, 'N')") or die(mysql_error());
变量为$itemID(5位数字),$delivery(5位数字),$totalprice(交易成本),例如137.97和'N',在我的表中的装运字段中使用

我认为问题来自$totalprice,但是当我回显这行之前的所有变量时,它们似乎是正确的。下面是$totalprice为170时echo的错误示例:

00036 00022 N 170您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,了解第1行“order itemsID,deliveryDestinationID,total,shipped VALUES 00036,00022,170”附近使用的正确语法

有什么想法吗?

订单是一个问题。它是查询中的错误源。正如其他人建议的那样,将其括在后面的记号中,以便查询工作。

顺序是一个保留关键字。如果将其用作表名,则使用反勾号将其转义:

"INSERT INTO `order` (itemsID ...
秩序是一种挑战。若要将其用作表名或列名,必须将其括在反勾中

$orderDB = mysql_query("INSERT INTO `order` (itemsID, deliveryDestinationID, total, shipped) VALUES ($itemID, $delivery, $totalprice, 'N')") or die(mysql_error());
order在MySQL中是一个保留字。考虑更改表名或将其包装在回扣中,例如:“订单”< /P>
我确信括号是正确的。对于数据库字段和值的完整查询和单独查询谢谢您的工作,也感谢在同一3秒钟内发表评论的所有其他人: