MySQL列计数与第1行的值计数不匹配

时间:2023-02-10 20:03:26

I'm trying to insert data into a MySQL table using PHP, but getting the error

我正在尝试使用PHP将数据插入MySQL表,但得到错误

Column count doesn't match value count at row 1

列数与第1行的值计数不匹配

mysql_query("INSERT INTO file (id, filename, extention, filelink, filesize, filepass) VALUES('{$random}', '{$filename}', '{$extension}', '{$filelink}', '{$filesize}' '{$filepass}') ") or die(mysql_error());

2 个解决方案

#1


12  

mysql_query("INSERT INTO file (id, filename, extention, filelink, filesize, filepass) VALUES('{$random}', '{$filename}', '{$extension}', '{$filelink}', '{$filesize}' '{$filepass}') ") or die(mysql_error());

You should add the missing comma after {$filesize}:

您应该在{$ filesize}之后添加缺少的逗号:

mysql_query("INSERT INTO file (id, filename, extention, filelink, filesize, filepass) VALUES('{$random}', '{$filename}', '{$extension}', '{$filelink}', '{$filesize}', '{$filepass}') ") or die(mysql_error());

#2


7  

'{$filesize}' '{$filepass}' is being considered as a single value since you're missing the comma. Your query would look like:

'{$ filesize}''{$ filepass}'被认为是单个值,因为您错过了逗号。您的查询将如下所示:

INSERT INTO file (id, filename, extention, filelink, filesize, filepass)
VALUES ( '{$random}',
         '{$filename}',
         '{$extension}',
         '{$filelink}',
         '{$filesize}' '{$filepass}')

There. You have 6 columns and 5 values. The column count doesn't match the value count and hence MySQL throws an error message.

那里。您有6列和5个值。列数与值计数不匹配,因此MySQL会抛出错误消息。

#1


12  

mysql_query("INSERT INTO file (id, filename, extention, filelink, filesize, filepass) VALUES('{$random}', '{$filename}', '{$extension}', '{$filelink}', '{$filesize}' '{$filepass}') ") or die(mysql_error());

You should add the missing comma after {$filesize}:

您应该在{$ filesize}之后添加缺少的逗号:

mysql_query("INSERT INTO file (id, filename, extention, filelink, filesize, filepass) VALUES('{$random}', '{$filename}', '{$extension}', '{$filelink}', '{$filesize}', '{$filepass}') ") or die(mysql_error());

#2


7  

'{$filesize}' '{$filepass}' is being considered as a single value since you're missing the comma. Your query would look like:

'{$ filesize}''{$ filepass}'被认为是单个值,因为您错过了逗号。您的查询将如下所示:

INSERT INTO file (id, filename, extention, filelink, filesize, filepass)
VALUES ( '{$random}',
         '{$filename}',
         '{$extension}',
         '{$filelink}',
         '{$filesize}' '{$filepass}')

There. You have 6 columns and 5 values. The column count doesn't match the value count and hence MySQL throws an error message.

那里。您有6列和5个值。列数与值计数不匹配,因此MySQL会抛出错误消息。