Checking if mysql data exist
#1

Код:
new plrIP[16];
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
mysql_format(mysql, query, sizeof(query), "SELECT `IP` FROM `info` WHERE `ip` = '%e' LIMIT 1", plrIP);
mysql_query(mysql, query);
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    if(rows)
    {
    //exist
    }
    else if(!rows)
    {
    // doesnt exist
    }
what is wrong with this code? even if ip exists, this code always shows that it doesnt exist
Reply
#2

Try this
pawn Код:
new plrIP[16];
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
mysql_format(mysql, query, sizeof(query), "SELECT `IP` FROM `info` WHERE `IP` = '%e' LIMIT 1", plrIP);
new Cache:result = mysql_query(mysql, query);
new rows = cache_num_rows();
cache_delete(result);
if(rows) {
   
} else {
   
}
Reply
#3

does not work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)