PHP查询错误没有在执行查询时获取的值

时间:2017-10-18 16:23:49

标签: php html mysql html5 mysqli

<?php
    session_start();
    $dbname="Student";
    $conn = mysqli_connect('localhost','root','',$dbname);
    if (!$conn)
    {
        die("<script type='text/javascript'>alert('Connection Failed!')</script>".mysqli_connect_error());
    }
    else
    {
        $Email=$_POST['email'];
        $Password=$_POST['password'];
        echo $Email.$Password;
        $id="select Sid from studentdetails where Semail='$Email' and Spassword='$Password'";
        $result=mysqli_query($conn,$id);
        echo $result;
        $_SESSION["studentid"]=6;
        if($result)
        {
            if(mysqli_num_rows($result)>0)
            {

                echo "<script type='text/javascript'>alert('Login Succesfull!')</script>";
                echo "<script>setTimeout(\"location.href='StudentHomePage.php';\",800);</script>";
            }
            else
            {
                session_destroy(); 
                die("<script type='text/javascript'>alert('Could Not Login Succesfully!\\nUsername or Password Incorrect!');
                    setTimeout(\"location.href='StudentForm.html';\",800);</script>");
            }
        }
    }
?>

这是我的代码。我正在尝试接受用户从登录页面输入的电子邮件和密码,并检查数据库是否正确。如果正确,则获取Student id并将其分配给会话以将其传递到另一个页面并进一步获取结果。但$ result没有得到任何价值,而是给出了错误,即 https://gyazo.com/3cd2560fab3f6fa6931f8b0c79bf9a1d 当我回复电子邮件和密码时,它会被打印,但$ result不会。我还检查了列名和数据库连接等......并且工作正常。它只给这行代码一个错误。请帮我找到解决方案。

0 个答案:

没有答案