Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\project\sable.php on lin

Discussion in 'PHP' started by exzevia, Nov 1, 2010.

  1. #1
    PLease help me . am i missing a curly bracket or what i thought i closed all open brackets. may you also please help me in findind any other errors PHP hsnt detected right now i am stuck on this one. If i remove that curly bracket its giving me this error (Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\project\sable.php on line 62 )

    <?php
    session_start();
    require("config.php");
    require("functions.php");
    $db = mysql_connect($dbhost, $dbuser, $dbpassword);
    mysql_select_db(college_data_web, $db);
    if($_POST['submit']) {
    $sql = "SELECT * FROM users WHERE username = '"
    . $_POST['username'] . "' AND password = '"
    . $_POST['password'] . "';";
    $result = mysql_query($sql);
    $numrows = mysql_num_rows($result);
    if($numrows == 1) {
    $row = mysql_fetch_assoc($result);
    if($row['active'] == 1) {
    session_register("USERNAME");
    session_register("USERID");
    $_SESSION['USERNAME'] = $row['username'];
    $_SESSION['USERID'] = $row['id'];
    $_SESSION['USERNAME'] = $row['username'];
    $_SESSION['USERID'] = $row['id'];
    switch($_GET['ref']) {
    case "newpost":
    if(isset($_GET['id']) == FALSE) {
    header("Location: " . $config_basedir .
    "/newtopic.php");
    }
    else {
    header("Location: " . $config_basedir .
    "/newtopic.php?id=" . $_GET['id']);
    }
    break;
    case "reply":
    if(isset($_GET['id']) == FALSE) {
    header("Location: " . $config_basedir .
    "/newtopic.php");
    }
    else {
    header("Location: " . $config_basedir .
    "/newtopic.php?id=" . $_GET['id']);
    }
    break;
    default:
    header("Location: " . $config_basedir);
    break;
    }
    }
    else {
    require("header.php");
    echo "This account is not verified yet. You were emailed a link
    to verify the account. Please click on the link in the email to
    continue.";
    }
    echo "This account is not verified yet. You were emailed a link
    to verify the account. Please click on the link in the email to
    continue.";
    }
    }
    else {
    header("Location: " . $config_basedir . "/login.php?error=1");
    }
    }
    else {
    require("header.php");
    if($_GET['error']) {
    echo "Incorrect login, please try again!";
    }
    ?>
    <form action="<?php echo pf_script_with_get($SCRIPT_NAME); ?>"
    method="post">
    <table>
    <tr>
    <td>Username</td>
    <td><input type="text" name="username"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td><input type="password" name="password"></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" name="submit" value="Login!"></td>
    </tr>
    </table>
    </form>
    Don't have an account? Go and <a href="register.php">Register</a>!
    <?php
    }
    require("footer.php");
    ?>
     
    exzevia, Nov 1, 2010 IP
  2. mikecampbell

    mikecampbell Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yeah it looks like an extra } on line 57.

      }
    }
    else {
      header("Location: " . $config_basedir . "/login.php?error=1");
    }
    }
    PHP:
    should be

      }
      else {
        header("Location: " . $config_basedir . "/login.php?error=1");
      }
    }
    PHP:
    Also, make sure to call mysql_real_escape_string() on $_POST['username'] and $_POST['password'] or else you have a serious vulnerability on your hands.
     
    mikecampbell, Nov 1, 2010 IP