MYSQL Help!
#1

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

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

Oh! I see. Thank you so much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)