2017-09-14 33 views
0

我在嘗試運行一個INSERT語句時,出現以下錯誤:MySQL的INSERT INTO語法錯誤 - 稍新的用戶:)

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)"; 

任何有識之士將不勝感激。

謝謝!

回答

0

用下面的單引號括起你的文本/字符串值。

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