25.09.2010, 18:00
I trying to make a function that will switch the data in fields.
This code not working at all.
pawn Код:
new sscanfinput[64], string[128];
new name[24],
Escape[2][128];
GetPlayerName(playerid, name, 24);
mysql_real_escape_string(name, Escape[0]); // This function makes sure you don't get MySQL injected. Read about it by searching it on ******.
format(string, 128, "SELECT * FROM `playerinfo` WHERE user = '%s'", Escape[0]);
mysql_query(string);
new Query[1024];
new Query2[1024];
new Query3[1024];
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `key` = '%s' WHERE `user` = '%s'", PlayerInfo[playerid][pKey], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `level` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pLevel], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `admin` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pAdmin], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `donaterank` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pDonateRank], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `upgradepoints` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][gPupgrade], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `connectedtime` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pConnectTime], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `sex` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pSex], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `age` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pAge], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `ck` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pCK], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `muted` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pMuted], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `respect` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pExp], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `money` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pCash], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `ban` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pBan], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `reason` = '%s' WHERE `user` = '%s'", PlayerInfo[playerid][pReason], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `bank` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pAccount], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `crimes` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pCrimes], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `deaths` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pDeaths], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `kills` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pKills], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `arrested` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pArrested], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `wanteddeaths` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pWantedDeaths], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `phonebook` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pPhoneBook], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `job` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pJob], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `paycheck` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pPayCheck], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `jailed` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pJailed], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `jailtime` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pJailTime], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `jailday` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pJailday], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `jailmonth` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pJailmonth], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `jailyear` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pJailyear], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `jailar` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pJailar], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `materials` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pMats], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `drugs` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pDrugs], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `leader` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pLeader], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `member` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pMember], Escape[0]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `fmember` = '%d' WHERE `user` = '%s'", PlayerInfo[playerid][pFMember], Escape[0]);
mysql_query(Query);
mysql_free_result();
return 1;