MySQL login system
#1

Hello guys, I was reading a MySQL login/register tutorial. I was going to edit it for my needs as soon as I make sure it is working perfect. Everything is fine, it says MySQL database is connected etc. But when I connect to server, I see no log-in nor register dialogs. Here is the codes:

pawn Код:
public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid,-1,"{FF0000}(( {00FF00}[INFO]: {FFFFFF}Please wait while you are getting synced with the database. {FF0000}))");
    StopStats(playerid);
    new query[128];
    GetPlayerName(playerid, Name[playerid], 24);
    mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `server` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
    mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
    return 1;
}
and here is the "OnAccountCheck" callback:


pawn Код:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    if(rows)
    {
        cache_get_field_content(0, "PASS", pInfo[playerid][Password], mysql, 129);
        pInfo[playerid][sqlID] = cache_get_field_content_int(0, "sqlID");
        ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
    }
    return 1;
}
Reply
#2

try to use mysql_escape_string instead of "%e".
sometime i got this error too while using "%e"
Reply
#3

Put this under OnGameModeInit if you haven't:
pawn Код:
mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG);
Then go in game and run the server, and then go and check mysql_log.txt and show us what it said. Also just add:
pawn Код:
printf("%s", query);
Under:
pawn Код:
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
And let us know what that says too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)