解析错误:语法错误,意外$ end - 不知道我的代码错误

时间:2012-03-23 07:01:52

标签: syntax syntax-error

这是我的代码,它给了我一个意想不到的$ end错误,我似乎无法弄清楚它为什么。

我认为这可能是因为包含的文件,但是我在运行代码时遇到了同样的错误,并且保留了require文件行的注释。 它说错误在最后一行。

<?php

//mysql and functions


require ("dbconnect.php");
require ("functions.php");

//start session
session_start();
//authenticate session - PART I
if (!isset($_SESSION['email']))
{
    echo "Please login.. Redirecting";
    header("refresh:2;url=login.php");
    die();
}
else
{
    //session data
    $email = $_SESSION['email'];
    $firstname = $_SESSION['firstname'];
    $lastname = $_SESSION['lastname'];
    //check session data in database for second authentication
    $check = mysql_query("SELECT * FROM users WHERE email='$email' AND 
        firstname='$firstname' AND lastname='$lastname'") or die(mysql_error());
    if(is_resource($check) and mysql_num_rows($check)>0)
    {
        //success
    }
    else
    {
        echo "Session Expired. Login Again.";
        header("refresh:2;url=login.php");
        die();
    }
    echo "Hi, This is protected content that is only for logged in members.";
?>

1 个答案:

答案 0 :(得分:0)

如果从我之前的重新缩进中看不到,那么您最后错过了},结束了else