Checking if an IP exists in a table
#1

If coded this function:

pawn Код:
stock CheckBan(ip[])
{
    new
            szIp2[MAX_PLAYER_NAME],
            szQuery[128];

    mysql_real_escape_string(ip, szIp2, gMySQLConnection);
   
    format(szQuery, sizeof(szQuery), "SELECT `IP` FROM `bans` WHERE `IP` = '%s'", ip);
    mysql_query(gMySQLConnection, szQuery);
    if(cache_get_row_count(gMySQLConnection) > 0) return 1;
    return 0;
}
It returns 1, although 127.0.0.1 doesn't show up on the 'bans' table.

Here is the state of the 'bans' table:



Why would it return 1 and not 0?
Reply
#2

Nevermind, I've solved it.

I decided to let the script detect if the IP being checked exists in another method and it worked!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)