Loop through table and list out players with same IP
#3

Your query is fine. I wrote out an example for you:

PHP код:
stock SQL(playerid){
    
    new 
        
query[200]; 
        
    
mysql_format(MySQLquerysizeof query"SELECT * FROM accounts WHERE IP = '%e'"127.0.0.1); 
    
mysql_tquery(MySQLquery"IPAddressQuery""i"playerid);
    return 
1;

Using the '%e' specifier escapes special characters in a string for the use in a SQL statement. It prevents backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.

PHP код:
IPAddressQuery(playerid); public IPAddressQuery(playerid)
{
    if (!
cache_num_rows())
        return print(
"Accounts with that IP Address were not found.");
        
    new 
        
rString[128], rName[32]
    ; 
    
    for(new 
icache_num_rows(); i++){
        
cache_get_value(i"Name"rName);
        
        
format (rStringsizeof rString"Found '%s' with the IP address specified."rName); 
        
SendClientMessage(playerid, -1rString);
    }
        
    return 
1;

cache_num_rows() returns the number of rows found in the query.

We loop through the rows in the instance there are more than one account associated with the IP.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)