2013-04-15 24 views
0
執行MySQL查詢

在PHP我的SQL查詢如下:錯誤在PHP

mysql_query("insert into tbl_features (img_id,features_1,features_2,features_3,features_4,features_5,features_6,features_7,features_8,features_9,features_10,features_11,features_12,features_13,features_14,features_15,features_16,features_17) VALUES ($datas[$k],$contentsarray[19],$contentsarray[20],$contentsarray[21],$contentsarray[22],$contentsarray[23],$contentsarray[24],$contentsarray[25],$contentsarray[26],$contentsarray[27],$contentsarray[28],$contentsarray[29],$contentsarray[30],$contentsarray[32],$contentsarray[33],$contentsarray[34],$contentsarray[35],$contentsarray[36])") or die (mysql_error()); 

在執行它,我得到的錯誤:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1.0E-6)' at line 1

它只是插入13個DATAS當shoudl插入30,000。我無法弄清楚這裏的問題。 1.0E-6是第14列的最後數據。支架是問題嗎?

回答

2

你必須把'各地VARCHAR數據

mysql_query("insert into tbl_features (img_id,features_1,features_2,features_3,features_4,features_5,features_6,features_7,features_8,features_9,features_10,features_11,features_12,features_13,features_14,features_15,features_16,features_17) 
VALUES ('$datas[$k]','$contentsarray[19]','$contentsarray[20]','$contentsarray[21]','$contentsarray[22]' 
,'$contentsarray[23]','$contentsarray[24]','$contentsarray[25]','$contentsarray[26]' 
,'$contentsarray[27]','$contentsarray[28]','$contentsarray[29]','$contentsarray[30]', 
'$contentsarray[32]','$contentsarray[33]','$contentsarray[34]','$contentsarray[35]' 
,'$contentsarray[36]')") or die (mysql_error()); 
+0

感謝我曾試圖把「這也太,但它並沒有在那個時候,現在的工作時我再試一次沒關係。無論如何謝謝我不知道原因。 – user1583647

0

你需要把'各地varchar`數據

只要您插入varchar數據放在單引號這些數據。

('$datas[$k]','$contentsarray[19]','$contentsarray[20]'...................

0

當您使用arraydouble quotes,你應該圍繞他們braces{} 試試這個

mysql_query("insert into tbl_features (img_id,features_1,features_2,features_3,features_4,features_5,features_6,features_7,features  8,features_9,features_10,features_11,features_12,features_13,features_14,features_15,features_16,features_17) 
VALUES ('{$datas[$k]}','{$contentsarray[19]}','{$contentsarray[20]}',-----") or die (mysql_error());