我确实需要一些帮助来解释我的错误。我是关于mysqli的新手,有人借给我一些时间来教我关于mysqli的事吗?
<?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();
?>
答案 0 :(得分:-1)
当您在不使用其对象的情况下调用类的函数时,会出现问题中引用的错误。
问题是$link
$link
应该是一个mysqli对象,如:
$link = new mysqli("yourhost", "youruser", "yourpassword", "yourdb");