你能帮我们找出错误吗,谢谢你的帮助。
调用未定义的方法mysqli :: result()
<?php
function user_exists($username) {
$db = mysqli_connect("localhost","root","","sample");
$query = $db->query("SELECT COUNT(`id`) FROM `users` WHERE username = '$username'");
return ($db->result($query, 0) == 1) ? true : false;
}
?>
答案 0 :(得分:0)
尝试这样:
function user_exists($username) {
$db = mysqli_connect("localhost","root","","sample");
$result = $db->query("SELECT `id` FROM `users` WHERE username = '$username'");
return ($result->num_rows ? true : false);}