0

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

1
  • 1
    You're missing a comma in the values clause. Commented Aug 31, 2014 at 9:53

3 Answers 3

2

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')
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

You have to modify your query to this

insert INTO comments VALUES (NULL, '78', 'm man', '[email protected]', 'testh',  'unapprove')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.