Saving string as a symbol.. MySQL
#1

So I have this MySQL database everything works fine there's just one problem.. When I look at the variable "playerteam" it saves it as some random symbol..

It is saving the variable value as: я or C (я << Something other than civilian | C < Civ) but I wunna chnage this so It adds the real faction, below I will enter everything


Create the variable in structure:

pawn Код:
mysql_query("ALTER TABLE PlayerInfo ADD playerteam VARCHAR(225) NOT NULL DEFAULT 'CIV'");
When someone logs in:

pawn Код:
mysql_fetch_field_row(savingstring, "playerteam");
            strmid(PlayerInfo[playerid][playerteam], savingstring, 0, strlen(savingstring), 50);
When someone edits / logs out:

pawn Код:
format(query, sizeof(query), "UPDATE PlayerInfo SET playerteam='%s' WHERE user='%s'", PlayerInfo[playerid][playerteam], pname);
        mysql_query(query);
I thought it would be this:

pawn Код:
PlayerInfo[giveplayerid][playerteam] = team;
<< But when I edited this it crashed the server :/
Reply
#2

24 hours past - Bump.

Please can someone help me?!
Reply
#3

1) Try using "ADD COLUMN" over "ADD". You can also try removing that column and adding it back.

2) Don't use strmid for copying strings!

pawn Код:
#define strcpy(%0,%1) \
    strcat((%0[0] = '\0', %0), %1)

mysql_fetch_field_row(savingstring, "playerteam");
strcpy(PlayerInfo[playerid][playerteam], savingstring, 50);
3) This is the INCORRECT way:

pawn Код:
PlayerInfo[giveplayerid][playerteam] = team;
This is the correct way:

pawn Код:
strcpy(PlayerInfo[playerid][playerteam], team, 50);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)