警告:mysqli_query()需要至少2个参数,给定1个

时间:2014-03-08 20:26:41

标签: php login mysqli localhost warnings

当我在localhost中检查我的login.php时,我收到此错误消息。

Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\eduhub\login.php on line 39

SELECT * FROM stuacc WHERE email ='asdfghjklf@gmail.com'AND password ='aaaaeeee'LIMIT 1Query failed

我的代码是:

<?php
    session_start();

    $errmsg_arr = array();

    $errflag = false;

    include('db_conx.php');

    //Sanitize the POST values
    $u = $_POST['username'];
    $p = $_POST['password1'];

    //Create query
    $qry="SELECT * FROM stuacc WHERE email = '$u' AND password = '$p' LIMIT 1";
    $result=mysqli_query($qry);
    echo $qry;
    //Check whether the query was successful or not
    if($result) {
        if(mysqli_num_rows($result) > 0) {
            //Login Successful
            session_regenerate_id();
            $member = mysqli_fetch_assoc($result);
            $_SESSION['SESS_MEMBER_ID'] = $member['id'];
            $_SESSION['SESS_FIRST_NAME'] = $member['fname'];
            header("location: user.php");
            exit();
        }else {
            //Login failed
            header("location: index.php");
            exit();
        }
    }else {
        die("Query failed");
    }
?>

请帮我修理一下。

1 个答案:

答案 0 :(得分:0)

你应该提供mysqli_query 2 params:   - $ connection_link   - $ query_string。 或者从mysqli对象中调用它