Home » Php » php – Insert value list does not match column list: 1136 Column count doesn't match value count at row 1

php – Insert value list does not match column list: 1136 Column count doesn't match value count at row 1

Posted by: admin July 12, 2020 Leave a comment

Questions:

I see a lot of people having this issue but all the answers always point to the count not matching the value count but they both have 9 items so not sure why its giving me such an error? Guess i’ve missed the obvious?

    $sth = "INSERT INTO `docs` (title, ref, rev, content, owner, contract_id, cat_id, created, updated)
                VALUES (:title, :ref, :rev, :content, :owner, :contract :cat, NOW(), NOW())";
    $q = $conn->prepare($sth);
    $q->execute(array(':title'=>$title, ':ref'=>$ref, ':rev'=>$rev, ':content'=>$contnet, ':owner'=>$owner, ':contract'=>$contract, ':cat'=>$cat));
How to&Answers:

You’re missing a comma here: (in the VALUES())

:contract :cat

This

$sth = "INSERT INTO `docs` (title, ref, rev, content, owner, contract_id, cat_id, created, updated) VALUES (:title, :ref, :rev, :content, :owner, :contract :cat, NOW(), NOW())";

Should be

 $sth = "INSERT INTO `docs` (title, ref, rev, content, owner, contract_id, cat_id, created, updated) VALUES (:title, :ref, :rev, :content, :owner, :contract, :cat, NOW(), NOW())";