Search code examples
phpsqlformsmysql-workbenchworkbench

Column count doesn't match value count at row 1 error message, php / sql


I have to make a webpage using PHP and MySQL workbench to collect form data and I keep getting this error:

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

This is what my code looks like:

$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')";

and this is what it looks like in workbench:

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

I've tried it with an without the id and the 0 value, and neither work. Does anyone know how to fix this?


Solution

  • Your code

    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')
    

    Has an error exactly between 4 and 5 the apostrophes are misspaced

    It must look like this

    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')