在php中将函数转换为MySQLi

时间:2014-05-03 01:18:39

标签: php mysql mysqli

您好,我试图将以下功能转换为MySQLi。我已经做了一些但我无法弄清楚其余部分。你能救我吗?

function user_exists($username) {
$connect = mysqli_connect("host", "user", "password", "table") or die("Sorry, we are experiencing technical difficulties. Please try again later.");

$username = sanitize($username);
$query = mysqli_query($connect, "SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'");
return (mysql_result($query, 0) == 1) ? true : false;
}

1 个答案:

答案 0 :(得分:0)

你正在混合使用mysqli和mysql函数。你是否使用mysqli_result