SA-MP Forums Archive
MySQL help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL help (/showthread.php?tid=370141)



MySQL help - 963852741 - 19.08.2012

hey,
I've made a register 'n' login system with a MYSQL. Now, this is my login stock:
pawn Код:
stock LoginPlayer(playerid,const password[])
{
    new string[200];
    new EscapedText[60];
    mysql_real_escape_string(password, EscapedText);
    format(string,sizeof(string),"SELECT FROM `account` WHERE `Username` = '%s' AND `Password` = '%s'",GetName(playerid),EscapedText);
    mysql_query(string);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        SendClientMessage(playerid,COLOR_DARKGREEN,"You have been logged in!");
        LoadStats(playerid);
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,"You've entered wrong password. Will be kicked due to security reasons.");
        Kick(playerid);
    }
    mysql_free_result();
    return 1;
}
Now, when I login, it was supposed to write something, and it didn't. I haven't even login. I can write any password and I can respawn. Otherwise, it doesn't load my stats.
How can I make an if() that will check if the password contains the data of the columm on the MYSQL?


Re: MySQL help - ryansheilds - 19.08.2012

I don't get what you mean but I think you need to add a wildcard after 'SELECT' on the query ('*' - "SELECT * FROM...")