首页 > 解决方案 > 列数与第 1 行错误消息中的值计数不匹配,php / sql

问题描述

我必须使用 PHP 和 MySQL 工作台制作一个网页来收集表单数据,并且我不断收到此错误:

INSERT INTO tools ( id, tool1, tool2, tool3, tool4, tool5, tool6, tool7, tool8, tool9, tool10) VALUES ( '0','1', '2', '3', '4,' '5', '6', '7', '8', '9', '10')

INSERT failed: INSERT INTO tools ( id, tool1, tool2, tool3, tool4, tool5, tool6, tool7, tool8, tool9, tool10) VALUES ( '0','1', '2', '3', '4,' '5', '6', '7', '8', '9', '10')

Column count doesn't match value count at row 1

这就是我的代码的样子:

$query = "INSERT INTO tools ( id, tool1, tool2, tool3, tool4, tool5, tool6, tool7, tool8, tool9, tool10) VALUES ( '0','1', '2', '3', '4,' '5', '6', '7', '8', '9', '10')";

这就是它在工作台中的样子:

INSERT INTO tools (id, tool1, tool2, tool3, tool4, tool5, tool6, tool7, tool8, tool9, tool10) VALUES ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

我已经尝试过没有 id 和 0 值,但都不起作用。有谁知道如何解决这一问题?

标签: phpsqlformsmysql-workbenchworkbench

解决方案


你的代码

INSERT INTO tools ( id, tool1, tool2, tool3, tool4, tool5, tool6, tool7, tool8, tool9, tool10) 
VALUES ( '0','1', '2', '3', '4,' '5', '6', '7', '8', '9', '10')

恰好在 4 到 5 之间有一个错误,撇号错开

它必须看起来像这样

INSERT INTO tools ( id, tool1, tool2, tool3, tool4, tool5, tool6, tool7, tool8, tool9, tool10) 
VALUES ( '0','1', '2', '3', '4', '5', '6', '7', '8', '9', '10')

推荐阅读