2013-01-21 65 views
1

嗨,我得到這個錯誤,這是我的查詢MySQL的錯誤行1 INSERT INTO]

insert into `products` (original_id,name,image_url,buy_url,short_description,long_description,sale_price,retail_price,brand,keyword,category_name,store_name,provider_name) values (5068122-EC1155705-5.5M,Eastland Plainview Shoes (Black) - Women's Shoes - 5.5 M,http://www.shoes.com/productimages/shoes_iaec1155705.jpg,http://gan.doubleclick.net/gan_click?lid=41000000025255752&pid=5068122-EC1155705-5.5M&adurl=http%3A%2F%2Fwww.shoes.com%2FShopping%2Fproductdetails.aspx%3Fcatalog%255Fname%3Dweb%26pg%3D5068122%26p%3DEC1155705&usg=AFHzDLv0Y4C7BN1pbi4RzmWWTgLx7J7uBw&pubid=21000000000526055,Eastland keeps it timeless and classy with these smart and sturdy Plainview oxfords. Soft full grain leather upper in a casual oxford style with a round plain toe. Contouring double stitching and an Eastland side logo tag add classic detail. Five eyelet g,Eastland keeps it timeless and classy with these smart and sturdy Plainview oxfords. Soft full grain leather upper in a casual oxford style with a round plain toe. Contouring double stitching and an Eastland side logo tag add classic detail. Five eyelet grommeted lacing and a smooth leather padded collar and tongue create a comfortable customizable fit. Textile lining and cushioning footbed flexible stitched midsole. Durable polyurethane traction outsole with a sturdy 1 1/4 inch heel.,77.00,77.00,Eastland,Eastland Plainview Shoes (Black) - Women's Shoes - 5.5 M Womens|Casual Eastland US adult Black female Apparel & Accessories > Shoes 5.5 M,Apparel & Accessories > Shoes,Eastland,gan) 

線:127文件C:\網絡\ filesearch \的index.php你有一個錯誤你的SQL語法;檢查與您的MySQL服務器版本相對應的手冊,以便在'M,Eastland Plainview Shoes(Black) - Women's Shoes - 5.5 M,http://www.shoes.com/'在第1行使用正確的語法附近使用

這是什麼錯?

線線:127是這個

mysql_query($query) or die($query . "<br />On line: " . __LINE__ . " File " . __FILE__ . " " . mysql_error()); 
+0

我強烈建議您仔細閱讀,以保護自己免受SQL注入攻擊,並使用mysqli或PDO代替棄用的mysql_函數。 –

回答

2

行情查詢中附上您的字符串值。你有很大的字符串,但他們周圍沒有引號,那就是錯誤。例如5068122-EC1155705-5.5M應該是"5068122-EC1155705-5.5M"'5068122-EC1155705-5.5M'

+0

是的,或者通過使用查詢參數來避免整個問題。 –

+0

嗨,你好,謝謝你的迴應,但它並沒有解決我的問題..仍然存在相同的錯誤 – Alex

+1

,因爲你必須爲每個字符串值,而不僅僅是一個 –

1

對於在將它們用引號引起來後插入的值也使用mysql_escape_string。

0

讓我看看代碼。我會想出一些東西

+0

是的,我使用QOUTES,但它不能解決問題 – Alex

+0

@Roger這句話不正確,你也可以爲FLOAT和其他數值做這樣的事情 –

0

請更新與您的新查詢文章。如果用QUOTES正確更新了查詢,則下一個問題可能是數據類型不匹配或者字符串與定義的列之間的長度不匹配。