SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Resident Boozehound simontheak's Avatar
    Join Date
    Jun 2003
    Location
    _root.europe.uk.london
    Posts
    965
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with INSERT query

    Can someone explain where I'm going wrong with this?

    PHP Code:
    $sql=mysql_query("INSERT INTO customers (first_name, last_name,
            email_address, add1, add2, town, county, postcode, phone, referral)
            VALUES('
    $firstname', '$surname', '$email', '$add1', '$add2',
            '
    $add3', '$county', '$postcode', '$phone', '$hear', now())")
            or die (
    mysql_error()); 
    I'm getting the following error message, and I don't quite know why ...

    Code:
    Column count doesn't match value count at row 1
    Thanks loads in advance for your help ...

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    that's a pretty explicit error message

    what do you think it means?

    here, let me help by reformatting your SQL so that it's easier to read and easier to count the columns and the values
    Code:
    INSERT 
      INTO customers 
         ( first_name
         , last_name
         , email_address
         , add1
         , add2
         , town
         , county
         , postcode
         , phone
         , referral )         
    VALUES
         ( '$firstname'
         , '$surname'
         , '$email'
         , '$add1'
         , '$add2'
         , '$add3'
         , '$county'
         , '$postcode'
         , '$phone'
         , '$hear'
         , now() )
    i count 10 columns and 11 values, i.e. "column count doesn't match value count"

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Resident Boozehound simontheak's Avatar
    Join Date
    Jun 2003
    Location
    _root.europe.uk.london
    Posts
    965
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, feeling like a muppet now.

    Thanks very much for your time and patience though!


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
  •