我在php中的SQL查询如下:
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());
执行时我收到错误:
您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行的“1.0E-6”附近使用正确的语法
当shoudl插入30,000时,它只插入13个数据。我无法弄清楚这里的问题。 1.0E-6是第14列的最后一个数据。支架是问题吗?
答案 0 :(得分: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());
答案 1 :(得分:0)
您需要将'
放在varchar`数据
无论何时插入varchar数据,都要将这些数据放在单引号中。
喜欢('$datas[$k]','$contentsarray[19]','$contentsarray[20]'...................
答案 2 :(得分:0)
当您在array
中使用double 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());