Results 1 to 4 of 4

Thread: [RESOLVED] Unexpected } error message?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Resolved [RESOLVED] Unexpected } error message?

    Hello below i have posted my code, when i ran the code i got this message:

    Parse error: syntax error, unexpected '}' in /home/a1401476/public_html/adduser.php on line 28
    But how is it 'unexpected', don't i need that to end the if statement since right after that i go into the else...

    adduser.php : (i have enlarged line 28 to make it more noticable)
    Code:
    <?php
    if ($_POST[password1] == $_POST[password2]) {
    if ($_POST[email1] == $_POST[email2]) {
    if ((strlen($_POST[username]) > 0) & (strlen($_POST[username]) < 30)) {
    if ((strlen($_POST[password]) > 0) & (strlen($_POST[password]) < 30)) {
    if ((strlen($_POST[email]) > 0) & (strlen($_POST[email]) < 30)) {
    if ((strlen($_POST[securityq]) > 0) & (strlen($_POST[securityq]) < 50)) {
    if ((strlen($_POST[securitya]) > 0) & (strlen($_POST[securitya]) < 30)) {
    //-------------
    // if (username does not already exist)
    include("/Includes/database_info.php");
    $con = mysql_connect($servername,$username,$password);
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    mysql_select_db($servername, $con);
    $sql="INSERT INTO accounts (Username, Password, Email, SecurityQ, SecurityA) 
    VALUES ('$_POST[username]','$_POST[password1]','$_POST[email1]','$_POST[securityq]','$_POST[securitya]')";
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo ("Hello " . $_POST[username] . " , welcome to The School Truck."); 
    mysql_close($con)
    // if the username does exist then exit
    //-------------
    }
    else {
    echo "The length of your security anwser must be between 1 and 30 characters long.";
    }
    }
    else {
    echo "The length of your security question must be between 1 and 50 characters long.";
    }
    }
    else {
    echo "If you are getting this message but you have entered your email correctly then please contact us on the appropriate page.";
    }
    }
    else {
    echo "The length of your password must be between 1 and 30 characters long.";
    }
    }
    else {
    echo "The length of your username must be between 1 and 30 characters long.";
    }
    }
    else {
    echo "The two emails you entered did not match.";
    }
    }
    else {
    echo "The two passwords you entered did not match.";
    }
    
    
    ?>

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Unexpected } error message?

    look line 25, You're missing a semicolon at the end.
    My usual boring signature: Something

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Unexpected } error message?

    'Unexpected' means that the grammar requires a token before the one the parser is complaining about, so look leftwards and upwards (and you shall find the one dclamp mentions).

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: Unexpected } error message?

    Thank you, i never thought of the unexpected message like that before, though i don't know how i overlooked the missing semi-colon.

    This thread is resolved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width