php help

Discussion in 'PHP' started by cheesee, Jul 25, 2011.

  1. #1
    
    
    mysql_query("INSERT INTO movies (movie_name, imdb_rating, movie_description, movie_image, release_date, date_added)
          VALUES(
          '. {$_POST['movie-name']} .',
          '. {$_POST['imdb-rating']} .',
          '. {$_POST['movie-descripton']} .'
          '. $movie_image .',
          '. $release_date .',
          '. time() .'
          )") or die(mysql_error());
    
    Code (markup):

    Error: Column count doesn't match value count at row 1
    I can't figure out how to fix this query, if you can please help!
     
    cheesee, Jul 25, 2011 IP
  2. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    will it work better if you output the time() Function ..as a $time var?
     
    ezprint2008, Jul 25, 2011 IP
  3. cheesee

    cheesee Peon

    Messages:
    621
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nope still getting the same error.
     
    cheesee, Jul 25, 2011 IP
  4. akhil1311

    akhil1311 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You should convert the time to sql time or date format. Try this:

    mysql_query("INSERT INTO movies (movie_name, imdb_rating, movie_description, movie_image, release_date, date_added)
    VALUES(
    '{$_POST['movie-name']}',
    '{$_POST['imdb-rating']}',
    '{$_POST['movie-descripton']}',
    '$movie_image',
    '$release_date',
    '$added_date'
    )") or die(mysql_error());



    $added_date is the date which is in sql DATE format.
     
    akhil1311, Jul 26, 2011 IP
  5. suryawl

    suryawl Peon

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #5
    you miss comma in there so movie description and movie image join as one text


    
    
    mysql_query("INSERT INTO movies (movie_name, imdb_rating, movie_description, movie_image, release_date, date_added)
          VALUES(
          '. {$_POST['movie-name']} .',
          '. {$_POST['imdb-rating']} .',
          '. {$_POST['movie-descripton']} .',
          '. $movie_image .',
          '. $release_date .',
          '. time() .'
          )") or die(mysql_error());
    
    Code (markup):
     
    suryawl, Jul 26, 2011 IP