Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中执行mysql查询时出错_Mysql_Php - Fatal编程技术网

在php中执行mysql查询时出错

在php中执行mysql查询时出错,mysql,php,Mysql,Php,我在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,featu

我在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”附近使用的正确语法


当它应该插入30000个数据时,它只插入13个数据。我想不出这里的问题。1.0E-6是第14列的最后一个数据。那么括号就是问题所在吗?

您必须在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());

您需要在varchar`数据周围放置
'

无论何时插入varchar数据,都将这些数据放在单引号中


(“$datas[$k]”、“$contentsarray[19]”、“$contentsarray[20]”……

当您在
双引号中使用
数组时,应该用
大括号{}
试试这个

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

谢谢,我也试过放这个,但当时没用,现在我再放一次也没问题,我不知道原因,谢谢。