December 8th, 2012, 10:22 AM
I am new to php, but not programming, currently a Coldfusion Developer.
So i am trying to insert some data into a table in my db and I am getting the following error.
Column count doesn't match value count at row 1
Query: INSERT INTO powerball (p1, p2, p3,p4, p5, pb, DTE) VALUES ('32', '15', '15','35','35','49','14','12.08.12' )
as you can see the column/value count matches in the code
and here is the sql for the table
What is causing the error?
CREATE TABLE `powerball` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`p1` int(11) DEFAULT NULL,
`p2` int(11) DEFAULT NULL,
`p3` int(11) DEFAULT NULL,
`p4` int(11) DEFAULT NULL,
`p5` int(11) DEFAULT NULL,
`pb` int(11) DEFAULT NULL,
`valid_flag` varchar(20) DEFAULT 'Y',
`dte` date DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;
Does mysql require that I account for the Id and valid_flag fields eventhough the db populates them? [oracle guy here]
thanks for your input
December 8th, 2012, 10:43 AM
The error is very clear. You have 7 columns listed and 8 values.
There are 10 kinds of people in the world. Those that understand binary and those that don't.
December 8th, 2012, 12:44 PM
No, because they have a default value. If you were missing a column that required a value it would throw an error, but not the error you're getting.
December 8th, 2012, 07:37 PM
Ah, yes! As I like to say operator arrogance, I printed the values before and after the insert statement, and did not realize I listed one of the variables twice in the values section!
Originally Posted by gw1500se
Thanks again for the input it was greatly appreciated !