0

The query syntax is as follows:

INSERT INTO sent (username,password) VALUES 
 ('user','user2','user3','user4','user5','user6'),
 ('pass','pass2','pass3','pass4','pass5','pass6')

Resource: http://dev.mysql.com/doc/refman/5.5/en/insert.html

The mysql_error() always showing me this:

Column count doesn't match value count at row 1

I have no idea what should I do. Now it's time to ask you about this.

3
  • In this case I have to insert in each column 6 values, and I have two columns to operate. Commented Jun 15, 2014 at 23:03
  • 2
    You need to format it as INSERT INTO table (field1,field2) VALUES ('user', 'pass'),('user2','pass2') and so on Commented Jun 15, 2014 at 23:04
  • Ok I got the idea, thanks. Commented Jun 15, 2014 at 23:07

1 Answer 1

2

You specified 2 columns with 6 values. The number of columns and values has to match. What you want is this:

INSERT INTO sent (username,password) VALUES ('user','pass'),('user2','pass2'),('user3','pass3'),('user4','pass4'),('user5','pass5'),('user6','pass6')

See the MySQL documentation for more details:

INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas. Example:

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);

Sign up to request clarification or add additional context in comments.

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.