Helló!
A problémám az, hogy valami rejtélyes oknál fogva, a \"mysql_real_escape_string\" (mindegyik pluginnál)
elég ergyán mûködik. A gond az hogy mikor kikérek egy adatot az adatbázistól, még normálisan escapeli a játékos nevét, de ha többször próbálok adatot lekérni mindig beleilleszt egy \'Ü\' karaktert, ezáltal nem kéri le az adatot.
Adat lekérése:
E: A stock a játékos adatát kéri, nem a karakterét, de a lényege ugyanez, ugyanígy mûködik.
stock GetPlayerData( playerid, to_read[], size = sizeof(to_read), mit[] = \"nem\" )
{
new esced_playerName[ 24 + 1 ];
new temp_Name[ 24 + 1 ];
format( temp_Name, (24), \"%s\", PlayerName(playerid) );
mysql_real_escape_string( temp_Name, esced_playerName );
if( Compare(mit, \"nem\") )
{
format( Query, sizeof(Query), \"SELECT * FROM `players` WHERE `name` = \'%s\'\", esced_playerName );
}
else
{
format( Query, sizeof(Query), \"SELECT `%s` FROM `players` WHERE `name` = \'%s\'\", mit, esced_playerName );
}
mysql_query( Query );
mysql_store_result( );
mysql_fetch_row_format( to_read, \"|\" );
mysql_free_result( );
if( strlen(to_read) < 1 )
{
format( to_read, size, \"InvalidCharacter\" );
}
return true;
}
Kiolvasás:
stock LoadCharacter( playerid )
{
new g_Temp[ 64 + 1 ];
GetCharacterData( playerid, g_Temp, (64), \"money\" );
playerInfo[ playerid ][ Penz ] = strval( g_Temp );
GetCharacterData( playerid, g_Temp, (64), \"skin\" );
playerInfo[ playerid ][ Skin ] = strval( g_Temp );
GetCharacterData( playerid, g_Temp, (64), \"level\" );
playerInfo[ playerid ][ Szint ] = strval( g_Temp );
// -------------------------------------------------------------------------
SetPlayerSkin( playerid, playerInfo[ playerid ][ Skin ] );
GivePlayerMoney( playerid, playerInfo[ playerid ][ Penz ] );
SetPlayerScore( playerid, playerInfo[ playerid ][ Szint ] );
return 1;
}
A gond nem az hogy Invalid Character értéket kapok.. hanem hogy azt az értéket kapják meg, amit elõször kiolvasok. Jelen esetben minden érték a \'money\' mezõ értéke.
MySQL Log:
[17:53:20] >> mysql_real_escape_string( Connection handle: 1 )
[17:53:21] CMySQLHandler::EscapeString(Horváth Flórián); - Escaped 15 characters to Horváth Flórián.
[17:53:21] >> mysql_query( Connection handle: 1 )
[17:53:21] CMySQLHandler::Query(SELECT `money` FROM `p_chars` WHERE `name` = \'Horváth Flórián\') - Successfully executed.
[17:53:21] >> mysql_store_result( Connection handle: 1 )
[17:53:21] CMySQLHandler::StoreResult() - Result was stored.
[17:53:21] >> mysql_fetch_row_format( Connection handle: 1 )
[17:53:21] CMySQLHandler::FetchRow() - Return: 1500
[17:53:21] >> mysql_free_result( Connection handle: 1 )
[17:53:21] CMySQLHandler::FreeResult() - Result was successfully free\'d.
[17:53:21] >> mysql_real_escape_string( Connection handle: 1 )
[17:53:21] CMySQLHandler::EscapeString(HorvátÜ Flórián); - Escaped 15 characters to HorvátÜ Flórián.
[17:53:21] >> mysql_query( Connection handle: 1 )
[17:53:21] CMySQLHandler::Query(SELECT `skin` FROM `p_chars` WHERE `name` = \'HorvátÜ Flórián\') - Successfully executed.
[17:53:21] >> mysql_store_result( Connection handle: 1 )
[17:53:21] CMySQLHandler::StoreResult() - Result was stored.
[17:53:21] >> mysql_fetch_row_format( Connection handle: 1 )
[17:53:21] >> mysql_free_result( Connection handle: 1 )
[17:53:21] CMySQLHandler::FreeResult() - Result was successfully free\'d.
[17:53:21] >> mysql_real_escape_string( Connection handle: 1 )
[17:53:21] CMySQLHandler::EscapeString(HÜrvátÜ Flórián); - Escaped 15 characters to HÜrvátÜ Flórián.
[17:53:21] >> mysql_query( Connection handle: 1 )
[17:53:21] CMySQLHandler::Query(SELECT `level` FROM `p_chars` WHERE `name` = \'HÜrvátÜ Flórián\') - Successfully executed.
[17:53:21] >> mysql_store_result( Connection handle: 1 )
[17:53:21] CMySQLHandler::StoreResult() - Result was stored.
[17:53:21] >> mysql_fetch_row_format( Connection handle: 1 )
[17:53:21] >> mysql_free_result( Connection handle: 1 )
[17:53:21] CMySQLHandler::FreeResult() - Result was successfully free\'d.