MySQL query problem.
#1

Hello.

Does anyone know why this code doesn't work?

pawn Код:
stock PlayerRegister(playerid, password)
{
    new str[128];
    format(str,sizeof(str),"INSERT INTO users (username, password) VALUES ('%s', md5('%s'))", pName(playerid), password);
    mysql_query(str);
    format(str, sizeof(str),"You have registered as %s on %s.\nPlease confirm your password:",pName(playerid),SERVERNAME);
    ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login",str,"Login","Cancel");
}

stock PlayerLogin(playerid, password)
{
    new str[128];
    format(str, sizeof(str),"SELECT * FROM users WHERE username = '%s' AND password = md5('%s')",pName(playerid),password);
    mysql_query(str);
    mysql_store_result();
    if(!mysql_num_rows())
    {
        SendInfoMessage(playerid,"Wrong {a9c4e4}password{ffffff}! Kicked due to security reasons!");
        Kick(playerid);
        mysql_free_result();
        return 1;
    }
    else
    {
        SendInfoMessage(playerid,"Successfully logged in. Welcome back!");
        mysql_free_result();
        return 1;
    }
}
Everytime I try to log in it tells me I got the wrong password.
Reply


Messages In This Thread
MySQL query problem. - by introzen - 26.06.2013, 07:49
Re: MySQL query problem. - by [MG]Dimi - 26.06.2013, 08:08
Re: MySQL query problem. - by Vince - 26.06.2013, 08:16
Re: MySQL query problem. - by introzen - 26.06.2013, 08:37
AW: MySQL query problem. - by Skimmer - 26.06.2013, 09:52
Re: AW: MySQL query problem. - by introzen - 26.06.2013, 10:51

Forum Jump:


Users browsing this thread: 3 Guest(s)