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));
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.
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.
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())";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With