我必须使用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值的方法,但都没有用。有人知道如何解决这个问题吗?
答案 0 :(得分:0)
您的代码
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')