警告:mysqli_query()期望至少2个参数,其中1个给定:警告:mysqli_num_rows()期望参数1为mysqli_result,

时间:2019-02-05 17:19:03

标签: php mysql database

帮助..我在编码方面是新手,所以我在Google和Youtube上搜索了一些代码。

无论如何,这是我的源代码和错误。(我正在建立数据库)

<?php


$con =mysqli_connect("localhost", "root", "", "student");
if (mysqli_connect_errno()){
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else{

        if (isset($_POST['studentno'])) {

            $studentno = $_POST['studentno'];
            $password = $_POST['password'];

            $sql = "select * from data where studentno = '".$studentno."' AND password = ;'".$password."'
            limit 1";

            $result = mysqli_query($sql);

            if (mysqli_num_rows($result)==1){
                $message = "Successfully LoggedIn!";
        echo "<script type='text/javascript'>alert('$message');</script>";
        header('Location: output.html');
        exit();
            }
            else{
                $message = "Invalid Student# or Password!!";
        echo "<script type='text/javascript'>alert('$message');</script>";
        exit();
            }
        }
}

?>

错误是:

Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\Pictures\student.php on line 18

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\Pictures\student.php on line 20

请帮助我...我无法在Google和Youtube上找到任何解决方案...

0 个答案:

没有答案