SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Column Count doesnt match value count

    Hi.
    I have about 60 or more fields in my table,and I cant fill in all of them at the same time.E.g sometimes the user only fills in 20,or even 2.My problem here is that whenever I try to fill the table with the values(less than 60) it gives me the Column Count doesnt match value count at row 1 error.I have a field set as auto_increment and I use blank quotes('') to add to that field.But it still gives me the error.I have the fields set as NULL and their type as int in my table,could that be the problem?
    thx.

  2. #2
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anybody?this is urgent...

  3. #3
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed the properties of all the fields from NULL to NOT_NULL but it still doesnt seem to work.Here is the query that I'm trying to make:
    INSERT INTO table1 VALUES ('',1,11,12,13,2,21,22,23,3,31,32,33)
    All of the fields in my table are of int type.
    Can someone please tell me what I'm doing wrong?

  4. #4
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've got to be specific on what's going into the table, fieldnames & values. Here's a snippet from a 'simple' news script...
    PHP Code:
        $sql "
        INSERT INTO
            the_news
        SET
            date_posted = now(),
            event_region = '
    $_POST[posted_region]',
            event_type = 'news',
            event_start = '
    $_POST[event_start]',
            event_end = '
    $_POST[event_end]',
            is_announcement = '
    $_POST[news_announcement]',
            news_title = '
    $_POST[news_title]',
            news_details = '
    $_POST[news_detail]',
            news_notes = '
    $_POST[news_notes]',
            approved = '
    $_POST[approved]',
            display_after = '
    $_POST[show_after]'
            "

    You'll need to do something similar.
    Lats...

  5. #5
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.
    Nothing specific is going on in the table.Just about 60 fields,each of them is of int type and their maximum length is 6.and they're set to NOT NULL.thats all!

  6. #6
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, I think you may have missed my point - you need to set the field values according to the input values.

    Example, field_15 can only accept values from the 15th input statement on your form, field_16 can only accept values from the 16th input statement etc etc.

    Your table is expecting 60 values, so you need to give it either all 60 values, or specify the fieldnames like the example in my previous post.
    Lats...

  7. #7
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aah i got it.thanks bro.Lemme try it.

  8. #8
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more question,what should I set the auto incrementing field of the table as?Should I just specify no value for it and it would increment by itself?

  9. #9
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No value for auto_increment is good
    Lats...

  10. #10
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx,just wanted to confirm


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •