MySQL Query gone wrong. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL Query gone wrong. (
/showthread.php?tid=186843)
MySQL Query gone wrong. -
Toni - 30.10.2010
Hi there,
I am currently developing my TF2 server as you can see in my signature, and it's MySQL. The problem here is that when I leave, or 'update' my account with my function, my field 'ip' changes to 0.
Here is my function:
pawn Код:
function SavePlayerAccount(playerid)
{
new ip2[24];
GetPlayerIp(playerid, ip2, 24);
format(str, sizeof(str), "UPDATE `playerinfo` SET `ip` = '%s' AND `admin` = %d WHERE `user` = '%s'", ip2, pInfo[playerid][Admin], pName(playerid));
mysql_query(str);
printf("%s has just updated their account!", pName(playerid));
return 1;
}
And the logs say that it correctly queries my IP (or local).
But when I check in the table, our ip's are 0.
Re: MySQL Query gone wrong. -
smeti - 31.10.2010
pawn Код:
format(str, sizeof(str), "UPDATE `playerinfo` SET `ip` = '%s' AND `admin` = %d WHERE `user` = '%s'", ip2, pInfo[playerid][Admin], pName(playerid));
Change:
pawn Код:
format(str, sizeof(str), "UPDATE `playerinfo` SET `ip` = '%s', `admin` = '%d' WHERE `user` = '%s'", ip2, pInfo[playerid][Admin], pName(playerid));
//or:
format(str, sizeof(str), "UPDATE `playerinfo` SET `ip` = '%s' WHERE `user` = '%s' AND `admin` = '%d' ", ip2, pName(playerid), pInfo[playerid][Admin]);
Re: MySQL Query gone wrong. -
Toni - 31.10.2010
Quote:
Originally Posted by smeti
pawn Код:
format(str, sizeof(str), "UPDATE `playerinfo` SET `ip` = '%s' AND `admin` = %d WHERE `user` = '%s'", ip2, pInfo[playerid][Admin], pName(playerid));
Change:
pawn Код:
format(str, sizeof(str), "UPDATE `playerinfo` SET `ip` = '%s', `admin` = '%d' WHERE `user` = '%s'", ip2, pInfo[playerid][Admin], pName(playerid)); //or: format(str, sizeof(str), "UPDATE `playerinfo` SET `ip` = '%s' WHERE `user` = '%s' AND `admin` = '%d' ", ip2, pName(playerid), pInfo[playerid][Admin]);
|
I already tried both, but it's okay. I found a alternative way to do it. Thanks though