SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Hi, I directly give you the source code I'm using. The error message I always get is on the very same line. I've marked it below:

    if ( $submit == "submit" )
    {
    // check for subject and message
    if ( trim($author)=="" or trim($rating)=="" )
    {
    echo '"Please fill out the form completely and try again.<p><center><a href="review.php3">Back</a></center>"';
    exit();
    }
    else
    {
    $sql = mysql_query( "INSERT INTO reviews ( id, pid, author, date, rating, review ) VALUES ( '', $pid, $author, CURDATE(), $rating, $review );

    if (mysql_query($sql))
    {
    // here's the error (parse error), only this line
    // if I delete this whole if-statement, the parse error
    // appears at the very end of the document,
    // where nothing is written there, really strange...
    echo( "Your review has been added. Thank you for your contribution.<p>You can now close this window..." );
    }
    else
    {
    echo( "Ooops! An error occured while trying to add your review: " . mysql_error() );
    }
    }
    }
    else
    {
    echo ( "Unknown command!" );
    }


    Thanks for any help!

  2. #2
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    Found it!!!

    On line:
    $sql = mysql_query( "INSERT INTO reviews ( id, pid, author, date, rating, review ) VALUES ( '', $pid, $author, CURDATE(), $rating, $review );

    You are missing a closing double quote at the end of this line. The line needs to be like:

    $sql = mysql_query( "INSERT INTO reviews ( id, pid, author, date, rating, review ) VALUES ( '', $pid, $author, CURDATE(), $rating, $review ");

    PHP will often place the error message on the next line, since it doesn't know until then if you realy are done with a statement.


    --Daniel
    Fan of PHP, Photoshop, and Macs
    Andrew's Cars - My little brother's cars for Need for Speed 3

  3. #3
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Thanks! This problem is solved now. But here comes another... mySQL says, when inserting a row: Query was empty.

    $sql = mysql_query( "INSERT INTO reviews ( id, pid, author, date, rating, review ) VALUES ( '', $pid, $author, CURDATE(), $rating, $review )" );

    Any ideas?

    BTW, does it really pass on the content of the form fields, just by using the same var's name as the name of the HTML fields? Maybe I have to declare the vars first... if yes, how?

  4. #4
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    I may have found more of your problem.
    Code:
    $sql = mysql_query( "INSERT INTO reviews ( id, pid, author, date, rating, review ) VALUES ( '', $pid, $author, CURDATE(), $rating, $review ); 
    
    if (mysql_query($sql))
    Do you really mean to run mysql_query() twice?
    --Daniel
    Fan of PHP, Photoshop, and Macs
    Andrew's Cars - My little brother's cars for Need for Speed 3

  5. #5
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Yes, this must have been the problem, it works perfectly now. Thanks!

  6. #6
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your welcome!

    I get lots of practice debuging my own PHP code. Only once have I ever written anthing over ten lines that did not give me a parse error!
    My typing accuracy is atrocious!
    --Daniel
    Fan of PHP, Photoshop, and Macs
    Andrew's Cars - My little brother's cars for Need for Speed 3


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
  •