Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 [closed]

Tags:

php

pdo

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));
like image 280
twigg Avatar asked Jun 06 '13 10:06

twigg


People also ask

How do I fix error code 1136?

To fix this issue, make sure you're inserting the correct number of columns into the table. Alternatively, you can name the columns in your INSERT statement so that MySQL knows which columns your data needs to be inserted into.

What does it mean column count doesn't match value?

Column count doesn't match value count at row 1. That error message typically means the number of values provided in the INSERT statement is bigger or smaller than the number of columns the table has, while at the same time, you did not specify the columns to be inserted.


1 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())";
like image 149
Dale Avatar answered Sep 27 '22 22:09

Dale