第11行的PHP Script Parse Error意外'}'

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (54)

我是一个新的PHP程序员,所以我很难捕捉到错误。如果有人能解释错误,对我来说会有很大帮助

虽然在几个在线调试器中运行我的PHP我继续收到错误消息: 解析错误:语法错误,第11行意外'退出'(T_EXIT) 然而我不相信这是这样的...可能有人帮帮我

    <?php 

if (isset($_POST['submit'])) {
    include_once 'dbh.inc.php';


    $uid = $_POST['uid'];
    $pwd = $_POST['pwd'];

    if (empty($uid) || empty($pwd)) {
        header("Location: ../index.php")
        exit()
    } else {
        $sql = "SELECT * FROM users WHERE user_uid ='$uid'"; 
        $result= mysqli_querry($conn, $sql);
        $resultcheck = mysqli_num_rows($result);
        if ($resultcheck < 1) {
            header("Location: ../index.php")
            exit()
        } else {
            if ($row = mysqli_fetch_assoc($result)) {
                $hashedPwdCheck = password_verify($pwd, $row['user_pwd']);
                if ($hashedPwdCheck == false) {
                    header("Location: ../index.php")
                    exit()
                } elseif($hashedPwdCheck == true) {
                    $_SESSION['u_id'] = $row['user_id'];
                    $_SESSION['u_first'] = $row['user_first'];
                    $_SESSION['u_last'] = $row['user_last'];
                    $_SESSION['u_email'] = $row['user_email'];
                    $_SESSION['u_uid'] = $row['user_uid'];
                    echo "Correct";
                }
            }
        }
    }



} else { 
    header("Location: ../index.php?login=error")
    exit()

}

 ?> 
提问于
用户回答回答于

你缺少几个分号

// you have
if (empty($uid) || empty($pwd)) {
    header("Location: ../index.php")
    exit()

// you should have
if (empty($uid) || empty($pwd)) {
    header("Location: ../index.php") ;
    exit() ;


// you have 
} else { 
    header("Location: ../index.php?login=error")
    exit()

// you should have
} else { 
    header("Location: ../index.php?login=error") ;
    exit() ;

扫码关注云+社区

领取腾讯云代金券