MySQL Column Problem - 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)
+--- Thread: MySQL Column Problem (
/showthread.php?tid=652333)
MySQL Column Problem -
SeanDenZYR - 08.04.2018
Hello, i have this problem.
I manually added a table in PhpMyAdmin (not via SQL thing where you type in a code) via Structures > Add Column.
when i type /maketester in game, the command syntax is /maketester [playerid] [Level (1-2)].
i typed /maketester (My ID) 1. But when i checked MySQL via PhpMyAdmin, everyone's tester rank was set to 1, even if i specified ONLY my ID. And my code has no problem, as far as i know.
pawn Код:
CMD:maketester(playerid, params[])
{
new iPlayer, iRank;
if(sscanf(params, "ui", iPlayer, iRank)) return SendClientMessage(playerid, COLOR_GREY, "[Usage]: /maketester [PlayerID] [Level(1-2)]");
if(!(0 <= iRank <= 2))
{
return SendClientMessage(playerid, COLOR_GREY, "Invalid level. Valid levels range from 0 to 2.");
}
if(PlayerInfo[playerid][pAdmin] >= 6)
{
if(!IsPlayerConnected(iPlayer))
{
return SendClientMessage(playerid, COLOR_GREY, "The player specified is disconnected.");
}
if(!PlayerInfo[iPlayer][pLogged])
{
return SendClientMessage(playerid, COLOR_GREY, "That player hasn't logged in yet.");
}
PlayerInfo[iPlayer][pTester] = iRank;
SendClientMessageEx(iPlayer, COLOR_AQUA, "%s has set your Tester Level to {FF6347}%s{CFEFFC} (%i).", GetPlayerRPName(playerid), GetTesterRank(iPlayer), iRank);
SendClientMessageEx(playerid, COLOR_AQUA, "you have set %s's Tester Level to {FF6347}%s{33CCFF} (%i).", GetPlayerRPName(iPlayer), GetTesterRank(iPlayer), iRank);
mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET tester = %i", PlayerInfo[playerid][pTester]);
mysql_tquery(connectionID, queryBuffer);
}
return 1;
}
help please?
Re: MySQL Column Problem -
10MIN - 08.04.2018
I think you should see this:
https://dev.mysql.com/doc/refman/5.7/en/update.html
You aren't using any "WHERE" in your code, so it sets it for every record in the table... The correct query is:
PHP код:
mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET tester = %i WHERE name = %s", PlayerInfo[playerid][pTester], player_name);
mysql_tquery(connectionID, queryBuffer);
You will need to change `name` and `player_name`to whatever you use to identify your users...
Re: MySQL Column Problem -
SeanDenZYR - 08.04.2018
Oh, ok.
I am also new to MySQL, thanks for the help!