MySQL Query gone wrong.
#1

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.
Reply
#2

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]);
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)