10.08.2010, 14:44
Hi, I am getting a small problem with MySQL, I am still new to it so I have a hard time trying to create query's.
I am trying to update a player's admin level with this cmd.
I seem to get no errors when compiling but when I use the command in-game, I get a error in the console:
[MySQL] Error (0): Failed to store result.
and when I look in the MySQL Log it will be this :
So something is wrong with my query, it turns out, it will set every other's username to 0.
Can someone help me make it effect only 1 person?
Thanks again,
Toni
I am trying to update a player's admin level with this cmd.
pawn Код:
CMD:setlevel(playerid, params[])
{
new
id,
level,
str[128]
;
if(PlayerInfo[playerid][Admin] >= 5 || RconAdmin(playerid))
{
if(sscanf(params, "ui", id, level))
{
return SendClientMessage(playerid, LBLUE, "USAGE: /setlevel (playerid) (level)") &&
SendClientMessage(playerid, GREEN, "Function: Set a person a admin");
}
format(str, sizeof(str), "UPDATE `playerinfo` SET `Admin` = '%d' WHERE `User` = '%s'", level, pName(id));
mysql_query(str);
mysql_store_result();
format(str, sizeof(str), "|- Administrator %s has made %s (%d) admin level %d -|", pName(playerid), pName(id), id, level);
SendClientMessageToAll(ORANGE, str);
mysql_free_result();
}
else SendClientMessage(playerid, RED, "ERROR: You are not an admin!");
return 1;
}
[MySQL] Error (0): Failed to store result.
and when I look in the MySQL Log it will be this :
Код:
[Tue Aug 10 09:38:41 2010] Function: mysql_query executed: "UPDATE `playerinfo` SET `Admin` = '5' WHERE `User` = 'Toni'" with result: "0". [Tue Aug 10 09:38:41 2010] Function: mysql_store_result executed with result: "0" [Tue Aug 10 09:38:41 2010] Error (0): Failed to store result. [Tue Aug 10 09:38:41 2010] Function: mysql_free_result executed.
Can someone help me make it effect only 1 person?
Thanks again,
Toni