2011-09-14 58 views
0

以下是我表的模式(名稱 - > add_to_cart);MySQL錯誤而「插入」命令

add_to_cart_id int(10) PK 
created_date  timestamp 
ip_address  varchar(17) 
customer_id  int(11) 
session_id  varchar(1024) 
brand_id   int(11) 
product_id  int(11) 
sales_event_id int(11) 
quantity   int(11) 
referer   varchar(1024) 
user_agent  varchar(1024) 

但每當我試圖做執行以下查詢

INSERT INTO `add_to_cart` (add_to_cart_id,created_date,ip_address,customer_id,session_id,sku_id,product_id,sales_event_id,quantity,referer,user_agent) VALUES (1,2011-02-24 20:40:34,66.65.135.89,70154,qbk5r0rg9sl2ndiimquvnsab46,83791,308933,10105,2,https://www.onekingslane.com/product/10105/308933,Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/533.19.4 (KHTML); 

我收到以下錯誤

ERROR 1064(42000):你在你的SQL語法錯誤;請檢查與您的MySQL服務器版本對應的手冊,以便在 '20:40:34,66.65.135.89,70154,qbk5r0rg9sl2ndiimquvnsab46,83791,308933,10105,2,http' 附近使用 第1行ERROR 1064 (42000):你在你的SQL語法錯誤; 檢查手冊,對應於您的MySQL服務器版本的 正確的語法在第1行'U'附近使用錯誤1064(42000):您的SQL語法中有一個 錯誤;請檢查與您的 MySQL服務器版本對應的手冊,以找到在第1行'Intel Mac OS X 10_6_5'附近使用的正確語法錯誤1064(42000):SQL 語法中有錯誤;檢查對應於你的MySQL服務器版本 爲使用附近的正確的語法手冊「EN-US)爲AppleWebKit/533.19.4(KHTML)」 在1號線

我在做什麼錯。 謝謝。

回答

6

需要引用字符串值

INSERT INTO `add_to_cart` 
(
    add_to_cart_id, 
    created_date, 
    ip_address, 
    customer_id, 
    session_id, 
    sku_id, 
    product_id, 
    sales_event_id, 
    quantity, 
    referer, 
    user_agent 
) 
VALUES 
(
    1, 
    '2011-02-24 20:40:34', 
    '66.65.135.89', 
    70154, 
    'qbk5r0rg9sl2ndiimquvnsab46', 
    83791, 
    308933, 
    10105, 
    2, 
    'https://www.onekingslane.com/product/10105/308933,Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/533.19.4 (KHTML);' 
) 
+0

:)謝謝..這個偉大的工程! – Fraz

+0

什麼喬說 - 字符串單引號去,數字沒有。逃避你的字符串,不要逃避你的號碼。 – TehShrike

+0

嘿..是啊..計算器要求我等待一段時間之前,我接受一個答案..:P – Fraz