SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: PHP/SQL Error

Hybrid View

  1. #1
    SitePoint Member Msg.com's Avatar
    Join Date
    Jan 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP/SQL Error

    Query failed : INSERT INTO `feedback` VALUES (now(), 10, 's')Column count doesn't match value count at row 1

    Code:
    $ta_feedback = addslashes($ta_feedback);
    $query = "INSERT INTO `feedback` VALUES (now(), $rb_feedback, '$ta_feedback')";
    Can someone help please?

  2. #2
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your insert has more or less columns that are actually in the table.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  3. #3
    SitePoint Member Msg.com's Avatar
    Join Date
    Jan 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see the problem now, I was blind, it has 3 values to submit, and it's defining 5 rows on the table.

    Thanks.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If the other columns are nullable, then you can specify only three in the query, you just have to tell it which three:

    Code:
    INSERT INTO table (col2, col4, col5) VALUES (now(), $var, '$anothervar')

  5. #5
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman View Post
    If the other columns are nullable, then you can specify only three in the query, you just have to tell it which three:

    Code:
    INSERT INTO table (col2, col4, col5) VALUES (now(), $var, '$anothervar')
    They don't need to be nullable, so long as they have default values defined.
    PHP questions? RTFM
    MySQL questions? RTFM

  6. #6
    SitePoint Member Msg.com's Avatar
    Join Date
    Jan 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just changed the query to

    $query = "INSERT INTO `feedback` VALUES ('', '', now(), '$rb_feedback', '$ta_feedback')";


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
  •