Error on Debug.txt (MySQL) when player log in
#1

hello guys. it gives error on Debug.txt. this show when someone logs on in game

ERROR
pawn Код:
CMySQLHandler::Query(UPDATE `users` SET `IpAdress` ='127.0.0.1' WHERE Username = '[IEG]JakeS';) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
CMySQLHandler::FetchRow() - An error has occured. (Error ID: 2014, Commands out of sync; you can'
t run this command now)
Code
pawn Код:
stock LoginPlayer(playerid, password[])
{
    new Query[256],fetchVal[100];
    format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `Username` = '%s' AND `Password` = '%s' LIMIT 1;",PlayerName(playerid),password);
    mysql_query(Query);
    //
    format(Query, sizeof(Query), "UPDATE `users` SET `IpAdress` ='%s' WHERE Username = '%s';",GetIP(playerid),PlayerName(playerid));
    mysql_query(Query);
    //
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        while(mysql_fetch_row_format(Query, "|"))
        {
            mysql_fetch_field_row(fetchVal, "Money"); pInfo[playerid][pMoney] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Bankcash"); pInfo[playerid][BankMoney] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Score"); pInfo[playerid][Score] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Adminlevel"); pInfo[playerid][Adminlevel] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Army"); pInfo[playerid][Army] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "CIA"); pInfo[playerid][Cia] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "RegularPlayer"); pInfo[playerid][RegularPlayer] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Donator"); pInfo[playerid][Donator] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "OttoOwner"); pInfo[playerid][OttoOwner] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "TSkill"); pInfo[playerid][TerroristSkill] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "RobSkill"); pInfo[playerid][RobSkill] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "HasPackC4"); pInfo[playerid][HasPackC4] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "HasPackRope"); pInfo[playerid][HasPackRope] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "HasPackMoney"); pInfo[playerid][HasPackMoney] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "SavedWantedLevel"); pInfo[playerid][SavedWantedLevel] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "SavedJailTime"); pInfo[playerid][SavedJailTime] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Coprank"); pInfo[playerid][Coprank] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "HoursPlayed"); pInfo[playerid][HoursPlayed] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "MinutesPlayed"); pInfo[playerid][MinutesPlayed] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "SecondsPlayed"); pInfo[playerid][SecondsPlayed] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Banned"); pInfo[playerid][Banned] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Kills"); pInfo[playerid][Kills] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "Deaths"); pInfo[playerid][Deaths] = strval(fetchVal);

            mysql_fetch_field_row(fetchVal, "TotalHitFinished"); pInfo[playerid][TotalHitFinished] = strval(fetchVal);

        }
        mysql_free_result();
        LoggedIn[playerid] = 1;
        GivePlayerMoney(playerid, pInfo[playerid][pMoney]);//sets player money to last money he has
        SetPlayerScore(playerid, pInfo[playerid][Score]);//sets player score's to last score he has
        return SendClientMessage(playerid,-1,""red" >> "white"You have successfully logged in!");
        } else {
                ShowLoginScreen(playerid);
                SendClientMessage(playerid, -1,""red" >> "white"Incorrect Password. Please try again.");
        }
        return 1;
}
Reply
#2

pawn Код:
format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `Username` = '%s' AND `Password` = '%s' LIMIT 1;",PlayerName(playerid),password);
    mysql_query(Query);
    // store result now
    mysql_store_result();
Reply
#3

Put this
pawn Код:
format(Query, sizeof(Query), "UPDATE `users` SET `IpAdress` ='%s' WHERE Username = '%s';",GetIP(playerid),PlayerName(playerid));
    mysql_query(Query);
After mysql_free_result();
Reply
#4

Switch the SELECT and UPDATE query. There shouldn't be anything between selecting the rows and fetching them.
Reply
#5

Quote:
Originally Posted by Mr_DjolE
Посмотреть сообщение
pawn Код:
format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `Username` = '%s' AND `Password` = '%s' LIMIT 1;",PlayerName(playerid),password);
    mysql_query(Query);
    // store result now
    mysql_store_result();
Thanks

Quote:
Originally Posted by Adytza.
Посмотреть сообщение
Put this
pawn Код:
format(Query, sizeof(Query), "UPDATE `users` SET `IpAdress` ='%s' WHERE Username = '%s';",GetIP(playerid),PlayerName(playerid));
    mysql_query(Query);
After mysql_free_result();
Thanks

got it fixed it now. thanks verymuch!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)