Checking if mysql data exist - 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)
+--- Thread: Checking if mysql data exist (
/showthread.php?tid=631128)
Checking if mysql data exist -
ax1 - 23.03.2017
Код:
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
Re: Checking if mysql data exist -
Bwandon - 23.03.2017
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 {
}
Re: Checking if mysql data exist -
ax1 - 24.03.2017
does not work