SA-MP Forums Archive
Weird symbols instead of username from mysql query - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Weird symbols instead of username from mysql query (/showthread.php?tid=252412)



Weird symbols instead of username from mysql query - SaW_[VrTx] - 01.05.2011

Hello..
I'm getting weird error, while trying to save stats..
Log:
Quote:

[16:09:53] >> mysql_ping( Connection handle: 1 )

[16:09:53] CMySQLHandler::Ping() - Connection is still alive.

[16:09:53] >> mysql_query( Connection handle: 1 )

[16:09:53] CMySQLHandler::Query(UPDATE Users SET Password='asdlkjg',admin='0',score='1',wins='0',lo ses='0',points='0',plays='0',onlinetime='0',warnin gs='0' WHERE Name='ЂњшŌљ(D`|ґЉģ$@\x”°Ģč <Xtђ¬ČдSaW') - Successfully executed.

[16:09:53] >> mysql_query( Connection handle: 1 )

[16:09:53] CMySQLHandler::Query(UPDATE Users SET skin='',cc1='0',cc2='0',rims='0',nc='0',temp1='0', temp2='0',temp3='1' WHERE Name=' !") - An error has occured. (Error ID: 1064, 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 '' !"' at line 1)

Script:

pawn Код:
SavePlayer(playerid)
{
        if(!PlayerLogged[playerid])
        return 0;

//      PlayerInfo[playerid][score] = GetPlayerMoney(playerid);


        CheckMySQL();

        new string[256];
        format(string, sizeof(string), "UPDATE Users SET Password='%s',admin='%d',score='%d',wins='%d',loses='%d',points='%d',plays='%d',onlinetime='%d',warnings='%d' WHERE Name='%s'", PlayerInfo[playerid][Password], PlayerInfo[playerid][admin], PlayerInfo[playerid][score], PlayerInfo[playerid][wins], PlayerInfo[playerid][loses], PlayerInfo[playerid][points], PlayerInfo[playerid][plays], PlayerInfo[playerid][onlinetime], PlayerInfo[playerid][warnings]);
        mysql_query(string);
        format(string, sizeof(string), "UPDATE Users SET skin='%s',cc1='%d',cc2='%d',rims='%d',nc='%d',temp1='%d',temp2='%d',temp3='%d' WHERE Name='%s'", PlayerInfo[playerid][skin], PlayerInfo[playerid][cc1], PlayerInfo[playerid][cc2], PlayerInfo[playerid][rims], PlayerInfo[playerid][nc], PlayerInfo[playerid][temp1], PlayerInfo[playerid][temp2], PlayerInfo[playerid][temp3]);
        mysql_query(string);
        return 1;
}
Screenshot from db:


I tried to change username charset, varchar lenght, still same bug.. Where's the bug?

ps. I'm using G-sTyLeZzZ plugin.


Re: Weird symbols instead of username from mysql query - SchurmanCQC - 01.05.2011

In your format, the string declaration (%s) for WHERE Name='%s', isn't defined and given a value, hence there only being PlayerInfo[playerid][warnings], in the Float {...} parameter of your format.


Re: Weird symbols instead of username from mysql query - Sascha - 01.05.2011

" WHERE Name='%s'"
", PlayerInfo[playerid][Password], PlayerInfo[playerid][admin], PlayerInfo[playerid][score], PlayerInfo[playerid][wins], PlayerInfo[playerid][loses], PlayerInfo[playerid][points], PlayerInfo[playerid][plays], PlayerInfo[playerid][onlinetime], PlayerInfo[playerid][warnings]"

it would help you if you'd use "name" (GetPlayerName) for the %s lol...

edit: too slow -.-


Re: Weird symbols instead of username from mysql query - SaW_[VrTx] - 01.05.2011

oh.. Thanks, everything is working.