gpt4 book ai didi

php - mysql INSERT INTO 语法错误 - 新用户 :)

转载 作者:行者123 更新时间:2023-11-29 18:25:36 25 4
gpt4 key购买 nike

尝试运行 INSERT 语句时出现以下错误:

ERROR: INSERT INTO company (company, adr_street, city, Prov, postal, country) VALUES (company1, 67 46 street sw, city1, province1, w9w9w9, Canada) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '46 street sw, city1, province1, w9w9w9, Country)' at line 1

这是 vardump:

array(7) { ["company"]=> string(8) "company1" ["adr_street"]=> string(15) "67 46 street sw" ["city"]=> string(5) "city1" ["prov"]=> string(9) "province1" ["postal"]=> string(6) "w9w9w9" ["country"]=> string(6) "Canada" ["Submit"]=> string(6) "submit" }

这是查询:

$sql="INSERT INTO company (`company`, `adr_street`, `city`, `Prov`, `postal`, `country`) VALUES ($company, $adr_street, $city, $prov, $postal, $country)";

如有任何见解,我们将不胜感激。

谢谢!

最佳答案

用单引号将文本/字符串值括起来,如下所示。

INSERT INTO company (company, adr_street, city, Prov, postal, country) 
VALUES ('company1', '67 46 street sw', 'city1', 'province1', 'w9w9w9', 'Canada');

关于php - mysql INSERT INTO 语法错误 - 新用户 :),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46225073/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com