Login System
#1

Hello,

I've some issues with my login system.

pawn Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
    mysql_store_result();
    new type = resultid;
    new playerid = extraid;
    if(type == QUERY_LOGIN)
    {
        if(mysql_num_rows() != 0)
        {
            new str[256]; new data[20][256];
            mysql_fetch_row_format(str);
            explode(data,str,"|");
            PlayerInfo[playerid][pId] = strval(data[0]);
            PlayerInfo[playerid][pNiveau] = strval(data[3]);
            PlayerInfo[playerid][pExp] = strval(data[4]);
            PlayerInfo[playerid][pBan] = strval(data[5]);
            format(PlayerInfo[playerid][pBraison],256,"%s",data[6]);
            PlayerInfo[playerid][pAge] = strval(data[7]);
            PlayerInfo[playerid][pSexe] = strval(data[8]);
            PlayerInfo[playerid][pSpawnX] = strval(data[9]);
            PlayerInfo[playerid][pSpawnY] = strval(data[10]);
            PlayerInfo[playerid][pSpawnZ] = strval(data[11]);
            PlayerInfo[playerid][pSpawnVw] = strval(data[12]);
            PlayerInfo[playerid][pSpawnInt] = strval(data[13]);
            PlayerInfo[playerid][pArgent] = strval(data[14]);
            PlayerInfo[playerid][pBanque] = strval(data[15]);
            PlayerInfo[playerid][pAdmin] = strval(data[16]);
            format(PlayerInfo[playerid][pMail],256,"%s",data[17]);
            PlayerInfo[playerid][pSkin] = strval(data[18]);
            PlayerInfo[playerid][pTutoriel] = strval(data[19]);
            mysql_free_result();
            Spawn(playerid);
        }
        else
        {
       
            format(str, sizeof(str),"Mot de passe invalide.");
            TextDrawSetString(errormsg1[playerid],str);

        }
    }
pawn Код:
public Login(playerid,pass[])
{
    new EscapedText[60]; new Query[1000];
    mysql_real_escape_string(pass, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM comptes WHERE nom = '%s' AND `password` = '%s'",pName,EscapedText);
    mysql_query(Query,QUERY_LOGIN,playerid);
    return 1;
}
When I put my password, nothing happend.

Thanks in advance.
Reply
#2

You're not calling your OnQueryFinish function.

Код:
public Login(playerid,pass[])
{
    new EscapedText[60]; new Query[1000];
    mysql_real_escape_string(pass, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM comptes WHERE nom = '%s' AND `password` = '%s'",pName,EscapedText);
    mysql_query(Query,QUERY_LOGIN,playerid);
    return 1;
}
Should Be:

Код:
public Login(playerid,pass[])
{
    new EscapedText[60]; new Query[1000];
    mysql_real_escape_string(pass, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM comptes WHERE nom = '%s' AND `password` = '%s'",pName,EscapedText);
    new query = mysql_query(Query,QUERY_LOGIN,playerid);
   OnQueryFinish(query, QUERY_LOGIN, playerid);
    return 1;
}
I'm not sure why you have a connectionHandle parameter when you don't even use it.

Replace:
Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
With:
Код:
public OnQueryFinish(query[], resultid, extraid)
EDIT: Seems I'm wrong. Sorry.
Reply
#3

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
...
Do you even have the slightest idea what you're talking about? OnQueryFinish is a general purpose callback which is called by the MySQL plugin once the query is done processing. It should not be called directly as it'd probably result in more problems.

I quickly glanced over the original code and it seems to be correct, so show the logs and/or add debug prints.
Reply
#4

By adding debug prints

pawn Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
    mysql_store_result();
    new type = resultid;
    new playerid = extraid;
    if(type == QUERY_LOGIN)
    {
        printf("Query Login");
        if(mysql_num_rows() != 0)
        {
            printf("Co ok");
            new str[256]; new data[20][256];
            mysql_fetch_row_format(str);
            explode(data,str,"|");
            PlayerInfo[playerid][pId] = strval(data[0]);
            PlayerInfo[playerid][pNiveau] = strval(data[3]);
            PlayerInfo[playerid][pExp] = strval(data[4]);
            PlayerInfo[playerid][pBan] = strval(data[5]);
            format(PlayerInfo[playerid][pBraison],256,"%s",data[6]);
            PlayerInfo[playerid][pAge] = strval(data[7]);
            PlayerInfo[playerid][pSexe] = strval(data[8]);
            PlayerInfo[playerid][pSpawnX] = strval(data[9]);
            PlayerInfo[playerid][pSpawnY] = strval(data[10]);
            PlayerInfo[playerid][pSpawnZ] = strval(data[11]);
            PlayerInfo[playerid][pSpawnVw] = strval(data[12]);
            PlayerInfo[playerid][pSpawnInt] = strval(data[13]);
            PlayerInfo[playerid][pArgent] = strval(data[14]);
            PlayerInfo[playerid][pBanque] = strval(data[15]);
            PlayerInfo[playerid][pAdmin] = strval(data[16]);
            format(PlayerInfo[playerid][pMail],256,"%s",data[17]);
            PlayerInfo[playerid][pSkin] = strval(data[18]);
            PlayerInfo[playerid][pTutoriel] = strval(data[19]);
            mysql_free_result();
            Spawn(playerid);
        }
        else
        {
       
            format(str, sizeof(str),"Mot de passe invalide.");
            TextDrawSetString(errormsg1[playerid],str);

        }
    }
pawn Код:
public Login(playerid,pass[])
{
    new EscapedText[60]; new Query[1000];
    mysql_real_escape_string(pass, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM comptes WHERE nom = '%s' AND `password` = '%s'",pName,EscapedText);
    mysql_query(Query,QUERY_LOGIN,playerid);
    printf("Login");
    return 1;
}
pawn Код:
else if(clickedid == suivant)
        {
            if(pLogin[playerid] == 1)
            {
            ShowDialog(playerid, Show:LOGIN,DIALOG_STYLE_PASSWORD,"Connexion а SyndraRP.","Entrez votre mot de passe:","Connexion","");
            printf("ShowDial");
            }
pawn Код:
public Spawn(playerid)
{
    printf("Spawn");
    new str[80];
    format(str, sizeof(str),"Bienvenue %s.",PlayerInfo[playerid][pNom]);
    SendClientMessage(playerid, COLOR_BLUE, str);
    TogglePlayerControllable(playerid,1);
    CancelSelectTextDraw(playerid);
    PlayerInfo[playerid][pLogged] = 1;
    TextDrawHideForPlayer(playerid,box0);
    TextDrawHideForPlayer(playerid,box1);
    TextDrawHideForPlayer(playerid,titre1[playerid]);
    TextDrawHideForPlayer(playerid,msg1[playerid]);
    TextDrawHideForPlayer(playerid,msg2[playerid]);
    TextDrawHideForPlayer(playerid,errormsg1[playerid]);
    TextDrawHideForPlayer(playerid,suivant);
    SetPlayerPos(playerid,PlayerInfo[playerid][pSpawnX],PlayerInfo[playerid][pSpawnY],PlayerInfo[playerid][pSpawnZ]);

}
I got :
ShowDial
Login
Login Query
Co ok
Reply
#5

Better check the MySQL Log. It'll show you what the problem is if it's coming from MySQL.
Reply
#6

I don't think it's come from MySQL, because the debug print bellow the query said that the query is succesfully executed.

I'll check the MySQL log now.
Reply
#7

Код:
[00:30:29]  

[00:30:29] ---------------------------

[00:30:29] MySQL Debugging activated (07/18/13)

[00:30:29] ---------------------------

[00:30:29]  

[00:31:04] >> mysql_query( Connection handle: 1 )

[00:31:04] CMySQLHandler::Query(SELECT * FROM comptes WHERE nom = 'Catherine_Rollins') - Successfully executed.

[00:31:04] >> mysql_store_result( Connection handle: 1 )

[00:31:04] CMySQLHandler::StoreResult() - Result was stored.

[00:31:04] >> mysql_num_rows( Connection handle: 1 )

[00:31:04] CMySQLHandler::NumRows() - Returned 1 row(s)

[00:31:04] >> mysql_free_result( Connection handle: 1 )

[00:31:04] CMySQLHandler::FreeResult() - Result was successfully free'd.

[00:31:07] >> mysql_real_escape_string( Connection handle: 1 )

[00:31:07] CMySQLHandler::EscapeString(test); - Escaped 4 characters to test.

[00:31:07] >> mysql_query( Connection handle: 1 )

[00:31:07] CMySQLHandler::Query(resultID) - Threaded query with id 1 started. (Extra ID: 0)

[00:31:07] CMySQLHandler::ProcessQueryThread(SELECT * FROM comptes WHERE nom = 'Catherine_Rollins' AND `password` = 'test') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)

[00:31:07] OnQueryFinish(1,"SELECT * FROM comptes WHERE nom = 'Catherine_Rollins' AND `password` = 'test'") - Called.

[00:31:07] >> mysql_store_result( Connection handle: 1 )

[00:31:07] CMySQLHandler::StoreResult() - Result was stored.

[00:31:07] >> mysql_num_rows( Connection handle: 1 )

[00:31:07] CMySQLHandler::NumRows() - Returned 1 row(s)
Here are the log.
Reply
#8

Can anyone help me please ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)