Reputation: 49
I'm getting a mysql error when running an insert statement. The error is:
#1136 - Column count doesn't match value count at row 1. The insert has 5 values, BUT the comment id is set to AUTO INC
The insert statement looks like this:
insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', '[email protected]', 'testh' 'unapprove')
The table looks like this
1) comment_id int(10) AUTO_INCREMENT 2) post_id int(10) 3) comment_name varchar(100) 4) comment_email varchar(100) 5) comment_text (text) 6) status (text)
Can anyone help? many thanks for your efforts
Upvotes: 0
Views: 79
Reputation: 274
You have to modify your query to this
insert INTO comments VALUES (NULL, '78', 'm man', '[email protected]', 'testh', 'unapprove')
Upvotes: 0
Reputation: 1072
You should add comma after 'testh' since it it a value for comment_text field.
insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES
('78', 'm man', '[email protected]', 'testh', 'unapprove')
Upvotes: 1
Reputation: 5260
You have make a mistake. You forget to set the comma between all values. Change you query from:
insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', '[email protected]', 'testh' 'unapprove')
to
insert INTO comments (post_id, comment_name, comment_email, comment_text, status) VALUES ('78', 'm man', '[email protected]', 'testh', 'unapprove')
Upvotes: 2