SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Insert 3 values into 3 named columns - or not...

    Hi guys,

    Trying to insert 3 values into my db as below. All variables contain data, but I get the message: Column count doesn't match value count at row 1

    Googled it and but cannot see the problem. Date is TIMESTAMP so autofills, and rid is auto increment.

    Help?

    PHP Code:
     $sqlquery "INSERT INTO leads_comments (id, comment, user) VALUES ('" $_POST['id'] . "', '" $_POST['comment'] . '", "' $_SESSION['uid'] . "')";
          
    $result mysql_query($sqlquery) or die(mysql_error()); 
    Code:
      rid  int(11) auto_increment (primary key)			 
      id  int(11)			
      comment  text				
      user  text			   
      date  timestamp(14)

  2. #2
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is the error message in error?

    Do you need the single quotes round the id value if the id field is an int?

    It would be helpful to see the actual sql statement, ie can you echo $sqlquery?

    Mike

  3. #3
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ya, spotted it - double quotes and single quotes the wrong way around between the 2nd and 3rd variables.

    Ta,

    Dan


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
  •