解析错误:语法错误,第104行C:\xampp\htdocs\trial\register.php中的文件意外结束

解析错误:语法错误,第104行C:\xampp\htdocs\trial\register.php中的文件意外结束,php,html,mysql,Php,Html,Mysql,它说: 解析错误:语法错误,第104行C:\xampp\htdocs\trial\register.php中的文件意外结束 当我执行localhost/trial/register.php时 第104行是我的html标记关闭的那一行。我不知道发生了什么请帮助。我正在尝试创建一个注册页面 session_start(); //check if logged in if (isset($_SESSION['id'])){ header("Location: i

它说:

解析错误:语法错误,第104行C:\xampp\htdocs\trial\register.php中的文件意外结束

当我执行localhost/trial/register.php时 第104行是我的html标记关闭的那一行。我不知道发生了什么请帮助。我正在尝试创建一个注册页面
    session_start();
    //check if logged in
    if (isset($_SESSION['id'])){
        header("Location: index.php");
    }

    if (isset($_POST['register'])){
        include_once("db.php");

        $username = strip_tags($_POST['username']);
        $password = strip_tags($_POST['password']);
        $password_confirm = strip_tags($_POST['password_confirm']);
        $email = strip_tags($_POST['email']);

        $username = stripslashes($username);
        $password = stripslashes($password);
        $password_confirm = stripslashes($password_confirm);
        $email = stripslashes($email);

        $username = mysqli_real_escape_string($db, $username);
        $password = mysqli_real_escape_string($db, $password);
        $password_confirm = mysqli_real_escape_string($db, $password_confirm);
        $email = mysqli_real_escape_string($db, $email);

        //encrypt the password
        $password = md5($password);
        $password_confirm = md5($password_confirm);

        //sql storage queries
        $sql_store = "INSERT into users (username, password, email) VALUES ('$username','$password','$email')";
        $sql_fetch_username = "SELECT username FROM users WHERE username='$username'";
        $sql_fetch_email = "SELECT email FROM users WHERE email='$email'";
        //setting up queries
        $query_username = mysqli_query($db, $sql_fetch_username);
        $query_email = mysqli_query($db, $sql_fetch_email);

        //check for matches, incomplete entry, errors or for email already in use
        if(mysqli_num_rows($query_username)){
            echo"There is already a user with that name!";
            return;
        }

        if($username == ""){
            echo"Please enter a username!";
            return;
        }

        if($password == "" || $password_confirm==""){
            echo"Please enter your password!";
            return;
        }


        if($password !=$password_confirm){
            echo"The passwords do not match!";
            return;
        }


        if (!filter_var($email, FILTER_VALIDATE_EMAIL) || $email ==""){
            echo"This email is not valid!";
            return;
        }

        if (mysqli_num_rows($query_email)){
            echo"That email is already in use!";
            return;
        }

        mysqli_query($db, $sql_store);
        header("Location: index.php");
?> 


<!DOCTYPE html>
<html>
    <head>
        <title>PQ</title>
        <link rel="stylesheet" type="text/css" href="style.css">
        <script src="main.js"></script>
    </head>

    <body>
        <div data-role="page" id="Welcome">
            <div data-role="header">
                <h1>Welcome</h1>                    
            </div>
            <div role="main" id="loginform">
                <form method="post" action="register.php" enctype="multipart/form-data">
                    <input name="username" placeholder="Username" type="text">
                    <input name="password" placeholder="Password" type="password">
                    <input name="password_confirm" placeholder="Confirm Password" type="password">
                    <input name="email" placeholder="Email address" type="text">
                    <input name="register" type="submit" value="Register">
                </form> 
            </div>
            <div data-role="footer" data-position="fixed" data-theme="c">
                <h4>(C) 2016</h4>
            </div>
        </div>  
</body> 
</html>

此错误将仅显示最后一行。因为您还可以关闭最后一行中的结束括号。在您的情况下,您没有如ali所说关闭ifisset$\u POST['register']的括号。

您错过了ifisset$\u POST['register']的结束括号}{此if conditionuse exit here headerLocation:index.php;exit;它在我注册时起作用,但在我尝试注册时出现了这些错误:警告:include_oncedb.php:未能打开流:在第10行的C:\xampp\htdocs\trial\register.php中没有这样的文件或目录警告:include_once:未能打开“db.php”以包含include_path='C:\第10行C:\xampp\htdocs\trial\register.php中的xampp\php\PEAR注意:第22行C:\xampp\htdocs\trial\register.php中的未定义变量:db