duanhao4909 2018-05-04 07:16
浏览 77
已采纳

以下代码给出了Parse错误:语法错误,意外的T_VARIABLE

The following code gives Parse error: syntax error, unexpected T_VARIABLE. on line 8.

<?php 
    session_start();
    $email=$_REQUEST['email'];
    $password=$_REQUEST['password'];

    $con=mysqli_connect("localhost","root","","mydb");

    if(mysqli_fetch_array(mysqli_query($con,"select*from user101 where 
    email="$email" and password="$password"")))
    {
        $_SESSION['email']=$email;
        echo "login successful";
        header("Location:welcome.php");
    }
    else
    {
        echo "Login failed";
    }
?>
  • 写回答

4条回答 默认 最新

  • dougutuo9879 2018-05-04 07:20
    关注

    Try this because you had many double quotes and that is wrong.It should be like this " 'var' 'var' "

    <?php 
    session_start();
    $email=$_REQUEST['email'];
    $password=$_REQUEST['password'];
    
    $con=mysqli_connect("localhost","root","","mydb");
    
    if(mysqli_fetch_array(mysqli_query($con,"select*from user101 where 
    email='$email' and password='$password'")))
    {
    $_SESSION['email']=$email;
    echo "login successful";
    header("Location:welcome.php");
    }
    else
    {
    echo "Login failed";
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?