会话不起作用

时间:2013-07-25 10:38:15

标签: php

嗨我想开始一个用户会话,但我无法做到这一点。我也看到了它的例子,但我的问题仍然是一样的。我收到此错误

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a2277283/public_html/scripts/login.php on line 11

这是我的代码

<?php
    ob_start();
    session_start();
    include 'db.php';
    if (isset($_POST['submit'])) {
        echo $email = $_POST['user_email'];
        $sql = "select * from user where `user_email` = '$email'";
        if (mysql_query($sql)) {
            $_SESSION['email'] = $email;
            echo "$_SESSION['email']";
        }
    }
?>

2 个答案:

答案 0 :(得分:1)

问题是:

echo "$_SESSION['email']";

不使用引号,如:

echo $_SESSION['email'];

echo "$_SESSION[email]";

echo "{$_SESSION['email']}";

答案 1 :(得分:0)

PHP Docs

所述,回复会话变量:echo "{$_SESSION['email']}";