SA-MP Forums Archive
MySQL database! Data gets into wrong columns. - 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 database! Data gets into wrong columns. (/showthread.php?tid=564271)



MySQL database! Data gets into wrong columns. - iAnonymous - 20.02.2015

Hi,
I just converted my GM to MySQL but the problem is that my Score, Money and Headshots gets MESSED up.
Like score goes into Money's column and Headshots gets into Score's columns.

The players are getting annoyed.
Please tell me what are the possible reasons behind this and how can I fix it.
All comments will be highly appreciated.


Re: MySQL database! Data gets into wrong columns. - JeaSon - 20.02.2015

maybe you are getting and loading into wrong enum ? show code


Re: MySQL database! Data gets into wrong columns. - iAnonymous - 20.02.2015

So you mean wrong order of score money and headshots in saving and loading Enums?


Re: MySQL database! Data gets into wrong columns. - arakuta - 20.02.2015

Can you show us what you're exactly doing in code?


Re: MySQL database! Data gets into wrong columns. - Sledgehammer - 20.02.2015

Quote:
Originally Posted by iAnonymous
Посмотреть сообщение
So you mean wrong order of score money and headshots in saving and loading Enums?
Nope. Such as, When you load/ save/ update a player the player in the correct enums/ player data etc. Just double check these things.

If you'd like, because we can't be certain of your problem currently, Show some code perhaps?


Re: MySQL database! Data gets into wrong columns. - iAnonymous - 21.02.2015

Код:
forward MysqlLoadPlayer(playerid);
public MysqlLoadPlayer(playerid)
{
	new rows, fields;

    cache_get_data(rows, fields);
    if(rows)
    {
        new temp[128];

    	cache_get_row(0, 0, temp);
        PlayerInfo[playerid][UID] = strval(temp);
		cache_get_row(0, 1, temp);
		format(PlayerInfo[playerid][RegisterDate], 30, "%s", temp);
        cache_get_row(0, 2, temp);
        PlayerInfo[playerid][Level] = strval(temp);
        cache_get_row(0, 3, temp);
        PlayerInfo[playerid][Helper] = strval(temp);
        cache_get_row(0, 4, temp);
        PlayerInfo[playerid][dRank] = strval(temp);
        cache_get_row(0, 5, temp);
		format(PlayerInfo[playerid][Nick], 21, "%s", temp);
        cache_get_row(0, 6, temp);
		format(PlayerInfo[playerid][Password], 128, "%s", temp);
        cache_get_row(0, 7, temp);
        PlayerInfo[playerid][Kills] = strval(temp);
        cache_get_row(0, 8, temp);
        PlayerInfo[playerid][Deaths] = strval(temp);
        cache_get_row(0, 9, temp);
        PlayerInfo[playerid][Score] = strval(temp);
        cache_get_row(0, 10, temp);
        PlayerInfo[playerid][Money] = strval(temp);
        cache_get_row(0, 11, temp);
        PlayerInfo[playerid][Headshots] = strval(temp);

        GivePlayerCash(playerid, PlayerInfo[playerid][Money]);
	    SetPlayerScore(playerid, PlayerInfo[playerid][Score]);

	    format(query, sizeof(query), "SELECT * FROM `Prestiges` WHERE `Nick` = '%s'", escpname(playerid));
	    mysql_function_query(connectionhandle, query, true, "MysqlLoadPrestige", "i", playerid);

	    PlayerInfo[playerid][LoggedIn] = true;
            OnPlayerRequestClass(playerid, 0);
           return 1;
           }
Код:
SavePlayer(playerid)
{
	new score, money, kills, deaths, helper, donor, hs, string2[128];
    score = GetPlayerScore(playerid);
    money = GetPlayerCash(playerid);
    helper = PlayerInfo[playerid][Helper];
    donor = PlayerInfo[playerid][dRank];
    kills = PlayerInfo[playerid][Kills];
    deaths = PlayerInfo[playerid][Deaths];
    hs = PlayerInfo[playerid][Headshots];
    new Year, Month, Day;
    getdate(Year, Month, Day);
    format(string2, sizeof(string2), "%02d/%02d/%d",  Day, Month, Year);

    format(query, sizeof(query), "UPDATE `Accounts` SET `Helper`='%d', `Donor`='%d', `Score`='%d', `Money`='%d', `Kills`='%d', `Deaths`='%d', `Headshots`='%d', `laston`='%s' WHERE `Nick`='%s'",helper, donor, score, money, kills, deaths, hs, string2, GetName(playerid));
    mysql_function_query(connectionhandle, query, false, "", "");
    if(templevel[playerid] < 1)
    {
    	format(query, sizeof(query), "UPDATE `Accounts` SET `Admin`='%i' WHERE `Nick`='%s'", PlayerInfo[playerid][Level], GetName(playerid));
    	mysql_function_query(connectionhandle, query, false, "", "");
    }
    format(query, sizeof(query), "UPDATE `playeronlinetime` SET `ohours`='%d', `ominutes`='%d', `oseconds`='%d' WHERE `name`='%s'",PlayerInfo[playerid][hours],PlayerInfo[playerid][mins],PlayerInfo[playerid][secs],escpname(playerid));
    mysql_function_query(connectionhandle, query, false, "", "");
    format(query, sizeof(query), "UPDATE `Tag` SET `Allowed`='%d' WHERE `Nick`='%s'", PlayerInfo[playerid][Tag], GetName(playerid));
	mysql_function_query(connectionhandle, query, false, "", "");
}
Anything wrong here?


Re: MySQL database! Data gets into wrong columns. - Baboon - 21.02.2015

Check PHP my admin table whether it is really in that sequence.


Re: MySQL database! Data gets into wrong columns. - iAnonymous - 21.02.2015

Alright. Isn't the table sequence doesn't matters for MySQL?


Re: MySQL database! Data gets into wrong columns. - JeaSon - 21.02.2015

try to get row by row name
example
pawn Код:
forward MysqlLoadPlayer(playerid);
public MysqlLoadPlayer(playerid)
{
    new rows, fields;

    cache_get_data(rows, fields);
    if(rows)
    {
        new temp[128];

       

        PlayerInfo[playerid][UID] = cache_get_field_content_int(0, "ID"); // remeber use your column name this is an example
        cache_get_field_content(0,"RegisterDate", PlayerInfo[playerid][RegisterDate]);
        format(PlayerInfo[playerid][RegisterDate], 30, "%s", temp);
        PlayerInfo[playerid][Level] = cache_get_field_content_int(0, "Level");
        PlayerInfo[playerid][Helper] = cache_get_field_content_int(0, "Helper");
        PlayerInfo[playerid][dRank] = cache_get_field_content_int(0, "dRank");
        cache_get_field_content(0,"Password", PlayerInfo[playerid][Password]);
        cache_get_field_content(0,"Nick", PlayerInfo[playerid][Nick]);
        format(PlayerInfo[playerid][Nick], 21, "%s", temp);
        format(PlayerInfo[playerid][Password], 128, "%s", temp);
        PlayerInfo[playerid][Kills] = cache_get_field_content_int(0, "Kills");
        PlayerInfo[playerid][Deaths] = cache_get_field_content_int(0, "Deaths");
        PlayerInfo[playerid][Score] = cache_get_field_content_int(0, "Score");
        PlayerInfo[playerid][Money] = cache_get_field_content_int(0, "Money");
        PlayerInfo[playerid][Headshots] = cache_get_field_content_int(0, "Headshots");

        GivePlayerCash(playerid, PlayerInfo[playerid][Money]);
        SetPlayerScore(playerid, PlayerInfo[playerid][Score]);

        format(query, sizeof(query), "SELECT * FROM `Prestiges` WHERE `Nick` = '%s'", escpname(playerid));
        mysql_function_query(connectionhandle, query, true, "MysqlLoadPrestige", "i", playerid);

        PlayerInfo[playerid][LoggedIn] = true;
            OnPlayerRequestClass(playerid, 0);
           return 1;
           }



Re: MySQL database! Data gets into wrong columns. - iAnonymous - 21.02.2015

Anyone else?