SA-MP Forums Archive
MYSQL Help! - 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: MYSQL Help! (/showthread.php?tid=569791)



MYSQL Help! - TheCoopster - 02.04.2015

I am looking to make a command that lists all the usernames that are associated to an IP


How would I do it, would I do something like:

pawn Код:
(Take the string IP as if it were being entered in a sscanf param)

new query[128], ip[24], buffer[MAX_PLAYER_NAME];
format(query, sizeof(query),"SELECT `Username` FROM `Accounts` WHERE `IP` = '%s'", ip);
mysql_query(query);
mysql_store_result();

new rows = mysql_num_rows();
if(rows < 0) {
       SendClientMessage(playerid, COLOR_GREEN,"Accoutns Associated with that IP:");
       while(mysql_retrieve_row())
       {
              mysql_fetch_field_row(buffer, "Username"); sendClientMessageEx(playerid, COLOR_WHITE,"%s", buffer);
        }
}
mysql_free_result();

I've been looking for a way to do this for a while and I haven't quite found any tutorials for what I've been looking for, if anyone could please help with this I would be grateful for any help.


Re: MYSQL Help! - PowerPC603 - 02.04.2015

pawn Код:
if(rows > 0)
Rows can never be less than 0, you need to check if there are more than 0 rows.
You used < instead of >.


Re: MYSQL Help! - TheCoopster - 02.04.2015

Oh! I see. Thank you so much.