Whirlpool and MySQL
#1

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You are not registered", "Type your password below", "Register"," ");
        new pname[24],ip[50],escname[24],escpass[100],Query[300],buf[129];
        GetPlayerName(playerid, pname, sizeof(pname));
        mysql_real_escape_string(pname,escname);
        mysql_real_escape_string(inputtext,escpass);
        GetPlayerIp(playerid,ip,50);
        WP_Hash(buf,129,escpass);
        format(Query,300,"INSERT INTO `playerinfo` (`user`,`password`,`IP`,`kills`,`deaths`,`score`,`money`,`level`,`donor`) VALUES ('%s', '%s', '%s',0,0,0,0,0,0)",escname,buf,ip);
        mysql_query(Query);
        SendClientMessage(playerid,limegreen,"You have successfully registered!");
        PInfo[playerid][Regged] = 1;
        PInfo[playerid][Logged] = 1;
    }

    else if(dialogid == 2)
    {
        new pname[24],Query[200],escname[24],buf[129];
        GetPlayerName(playerid,pname,24);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
        mysql_real_escape_string(pname,escname);
        WP_Hash(buf,129,inputtext);
        format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = '%s'", escname, buf);
        mysql_query(Query);
        mysql_store_result();
        if(!mysql_num_rows())
        {
            SendClientMessage(playerid,RED,"ERROR: Invalid Password!");
            SetPVarInt(playerid,"MaxFails",GetPVarInt(playerid,"MaxFails") +1);
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
            if(GetPVarInt(playerid,"MaxFails") == 3)
            {
                new string[128];
                format(string,128,"%s has been kicked for failing to login",pname);
                SendClientMessageToAll(RED,string);
                Kick(playerid);
            }
           
        }
        else
        {
            new line[800];
            if(mysql_fetch_row(line)) //Fetches the line
            {
                   new data[3][100]; //The data strings
                   new data2[6]; //The data variables
                   sscanf(line, "p|sssdddddd",data[0],data[1],data[2],data2[0],data2[1],data2[2],data2[3],data2[4],data2[5]); //Splits the line with sscanf
                   PInfo[playerid][Kills] = data2[0];
                   PInfo[playerid][Deaths] = data2[1];
                   SetPlayerScore(playerid, data2[2]);
                   PInfo[playerid][Score] = data2[2];
                   PInfo[playerid][Cash] = data2[3];
                   GivePlayerMoney(playerid,data2[3]);
                   PInfo[playerid][Level] = data2[4];
                   PInfo[playerid][VIP] = data2[5];
                   new loginstring[128];
                   format(loginstring,128,"You have logged in! [Admin Level: %d] [Donor Level: %d] [Kills: %d] [Deaths: %d] [Score: %d] [Cash: %d]",PInfo[playerid][Level],PInfo[playerid][VIP],PInfo[playerid][Kills],PInfo[playerid][Deaths],PInfo[playerid][Score],PInfo[playerid][Cash]);
                   SendClientMessage(playerid,limegreen,loginstring);
                   mysql_free_result();
            }
        }
    }
        return 1;
}
PHP код:
Latest server log:
[
02:00:42] [join] [BFV]Wolf[COD5] has joined the server (0:76.30.89.140)
[
02:00:51] RCON (In-Game): Player #0 ([BFV]Wolf[COD5]) has logged in.
[02:00:56] [part] [BFV]Wolf[COD5] has left the server (0:1)
[
02:01:21] Incoming connection: 76.30.89.140:43993
[02:01:21] [join] [BFV]Wolf[COD5] has joined the server (0:76.30.89.140)
[
02:01:25] [MySQL] Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''3C6AF0B572CD9A00E8D04BC4642F4ADAC4BBC705F26B9B29A6494AAA14D4E218A3A99E0B7BF7945' at line 1.
[02:01:25] [MySQL] Error (0): Function: mysql_store_result called when no prior successful query executed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''3C6AF0B572CD9A00E8D04BC4642F4ADAC4BBC705F26B9B29A6494AAA14D4E218A3A99E0B7BF7945' 
at line 1.
[02:01:25] [MySQL] Error (0): Function: mysql_num_rows called when no result stored. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''3C6AF0B572CD9A00E8D04BC4642F4ADAC4BBC705F26B9B29A6494AAA14D4E218A3A99E0B7BF7945' at line 1.
[02:01:32] [MySQL] Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''5B29FCC224560C71A1F9BA9A546B9E82798F54071B6F76070F55FB2F3668FDC95F1D678D3DC1C86' 
at line 1.
[02:01:32] [MySQL] Error (0): Function: mysql_store_result called when no prior successful query executed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''5B29FCC224560C71A1F9BA9A546B9E82798F54071B6F76070F55FB2F3668FDC95F1D678D3DC1C86' at line 1.
[02:01:32] [MySQL] Error (0): Function: mysql_num_rows called when no result stored. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''5B29FCC224560C71A1F9BA9A546B9E82798F54071B6F76070F55FB2F3668FDC95F1D678D3DC1C86' 
at line 1.
[02:01:37] [MySQL] Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''6034BC99BF63372B3BFA27E1759AE8F337E35C113CC004FB1E7987D463CE301032B98C582BC1163' at line 1.
[02:01:37] [MySQL] Error (0): Function: mysql_store_result called when no prior successful query executed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''6034BC99BF63372B3BFA27E1759AE8F337E35C113CC004FB1E7987D463CE301032B98C582BC1163' 
at line 1.
[02:01:37] [MySQL] Error (0): Function: mysql_num_rows called when no result stored. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''6034BC99BF63372B3BFA27E1759AE8F337E35C113CC004FB1E7987D463CE301032B98C582BC1163' at line 1.
[02:01:37] [part] [BFV]Wolf[COD5] has left the server (0:2) 
Registering works fine, but logging in is the problem.
Reply
#2

pawn Код:
Query[200]
A Whirlpool password itself is 128 characters, plus 1 for the null terminator (totaling 129). You then have several other characters in the MySQL query, including more data being saved/loaded. Therefore, your query is not finishing and you begin receiving those errors. I hope this makes sense...
Reply
#3

Ah, thanks. I'll test it out..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)