以下代码给出了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";
    }
?>

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";
}
?>

you can write single quote in sqlstring solved this problem. But i suggest use mysql escape functions for prevent sql injections

<?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";
}

Replace your line number 8 with this -

if(mysqli_fetch_array(mysqli_query($con,"select * from user101 where 
email='$email' and password= '$password'")))

I hope this will help you!

It could be like this. avoid double quote inside the query when using double quote in outside

mysqli_query($con,"select*from user101 where 
email='$email' and password='$password'")