我需要关于这个错误的帮助:;致命错误:在C:url中的非对象上调用成员函数bind_param()


I need help about this error : "Fatal error: Call to a member function bind_param() on a non-object in C:url

我确实需要一些帮助来解释我的错误。我对优衣库很陌生,有人能借给我一些时间教我优衣库吗?

<?php
if(isset($_POST['txtlogin'])){
$username = $_POST['txtusername'];
    $password = md5($_POST['txtpassword']);
    $stmt = $link->prepare("SELECT username, password FROM users WHERE username=? AND  password=?");
    $stmt->bind_param('ss', $username, $password);
    $stmt->execute();
    $stmt->bind_result($username, $password);
    $stmt->store_result();
    if($stmt->num_rows == 1)  //To check if the row exists
        {
            while($stmt->fetch()) //fetching the contents of the row
              {$_SESSION['Logged'] = 1;
               $_SESSION['username'] = $username;
               echo 'Success!';
               exit();
               }
        }
        else {
            echo "INVALID USERNAME/PASSWORD Combination!";
        }
        $stmt->close();
    }
    else 
    {   
    }
$link->close();
?>

当您在不使用类的对象的情况下调用类的函数时,会出现问题中引用的错误。

问题是$link

$link应该是一个mysqli对象,比如:

$link = new mysqli("yourhost", "youruser", "yourpassword", "yourdb");