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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20683732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:25:14  来源:igfitidea点击:

MySQL column count doesn't match value count at row 1

phpmysql

提问by Nilay

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

回答by nowhere

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

回答by Amal Murali

'{$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 会抛出错误消息。