Thread: Insert issue

    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    Maryland
    Posts
    74
    Rep Power
    13

    Insert issue


    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
    Code:
    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;
    What is causing the error?

    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
    J. Birdsell,
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,336
    Rep Power
    594
    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.
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    Does mysql require that I account for the Id and valid_flag fields eventhough the db populates them? [oracle guy here]
    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.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    Maryland
    Posts
    74
    Rep Power
    13
    Originally Posted by gw1500se
    The error is very clear. You have 7 columns listed and 8 values.
    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!

    Thanks again for the input it was greatly appreciated !
    J. Birdsell,

IMN logo majestic logo threadwatch logo seochat tools logo