format(query2, 256, "SELECT cash,account,adminlevel,level,experience,upgradepoints,kills,gun1,gun2,gun3,ammo1,ammo2 FROM users WHERE username='%s'", playername2);
mysql_query(query2);
mysql_store_result(MySQL_Conn);
while(mysql_fetch_row_format(result, "|") == 1)
{
sscanf(result, "p<|>dddddddddddd",PlayerInfo[playerid][pCash],PlayerInfo[playerid][pAccount],PlayerInfo[playerid][pAdmin],PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pExp],PlayerInfo[playerid][gPupgrade],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pGun1],PlayerInfo[playerid][pGun2],PlayerInfo[playerid][pGun3],PlayerInfo[playerid][pAmmo1],PlayerInfo[playerid][pAmmo2]);
}
mysql_free_result(MySQL_Conn);
while(mysql_fetch_row(result)) {
new
data[12];
sscanf(result, "p<|>dddddddddddd", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11]);
PlayerInfo[playerid][pCash] = data[0];
PlayerInfo[playerid][pAccount] = data[1];
PlayerInfo[playerid][pAdmin] = data[2];
PlayerInfo[playerid][pLevel] = data[3];
PlayerInfo[playerid][pExp] = data[4];
PlayerInfo[playerid][gPupgrade] = data[5];
PlayerInfo[playerid][pKills] = data[6];
PlayerInfo[playerid][pGun1] = data[7];
PlayerInfo[playerid][pGun2] = data[8];
PlayerInfo[playerid][pGun3] = data[9];
PlayerInfo[playerid][pAmmo1] = data[10];
PlayerInfo[playerid][pAmmo2] = data[11];
}
format(query2, 256, "SELECT * FROM users WHERE username='%s'", playername2);
mysql_real_escape_string(query2); // Prevents SQL injection
while(mysql_fetch_row(result)) {
new
data[12];
sscanf(result, "p<|>dddddddddddd", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11]);
PlayerInfo[playerid][pCash] = data[0];
PlayerInfo[playerid][pAccount] = data[1];
PlayerInfo[playerid][pAdmin] = data[2];
PlayerInfo[playerid][pLevel] = data[3];
PlayerInfo[playerid][pExp] = data[4];
PlayerInfo[playerid][gPupgrade] = data[5];
PlayerInfo[playerid][pKills] = data[6];
PlayerInfo[playerid][pGun1] = data[7];
PlayerInfo[playerid][pGun2] = data[8];
PlayerInfo[playerid][pGun3] = data[9];
PlayerInfo[playerid][pAmmo1] = data[10];
PlayerInfo[playerid][pAmmo2] = data[11];
}
mysql_query(query2, -1, -1, MySQL_Conn);
mysql_fetch_row_format(data, "|", MySQL_Conn);
sscanf(data, "e<p<|>iiiii(data types)>", PlayerInfo[playerid]);
Query was incorrect
pawn Код:
|
mysql_real_escape_string(playername2,playername2);
format(query2, sizeof(query2), "SELECT * FROM `users` WHERE Username = '%s'", playername2);
';DROP *;
\'DROP *;
stock MySQLLoadVariables(playerid)
{
new
Query[500],
Name[MAX_PLAYER_NAME]
;
GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
format(Query,sizeof(Query),"SELECT * FROM `users` WHERE `username` = '%s'",Name);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row_format(Query,"|");
sscanf(Query, "p<|>dddddddddddd",PlayerInfo[playerid][pCash],PlayerInfo[playerid][pAccount],PlayerInfo[playerid][pAdmin],PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pExp],PlayerInfo[playerid][gPupgrade],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pGun1],PlayerInfo[playerid][pGun2],PlayerInfo[playerid][pGun3],PlayerInfo[playerid][pAmmo1],PlayerInfo[playerid][pAmmo2]);
mysql_free_result();
}