我正在努力将以下两个陈述转换为mysqli,有人可以帮忙吗?
代码如下:
function user_id_from_username($username) {
$username = sanitize($username);
return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `username` ='$username'"), 0,'user_id');
}
function login ($username, $password) {
$user_id = user_id_from_username($username);
$username = sanitize($username);
$password = md5 ($password);
return (mysql_result(mysql_query("SELECT COUNT (`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"),0)==1) ? $user_id : false;