将Mysql转换为Mysqli,两个函数

时间:2015-02-27 17:23:13

标签: php mysql mysqli

我正在努力将以下两个陈述转换为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;

0 个答案:

没有答案