Jump to content

Displaying multiple IP address(stored in DB) if more than 1 of same IP


slyte33

Recommended Posts

Hello, What I am trying to do is if a player's IP address is used twice(stored twice in DB; aka multiple accounts), then display their IP address and username.

 

For example:

 

IP addresses stored:

123.45.678.90

09.876.54.321

456.789.10.11

123.45.678.90

89.79.455.243

 

As you can see, 123.45.678.90 is stored twice, so display on webpage:

 

123.45.678.90 - [username for account one]

123.45.678.90 - [username for account two]

 

 

I hope this explains it, all help is much appreciated.

 

Thanks, Slyte :)

something like this...

 

$sql = mysql_query("SELECT * FROM users WHERE ip = '$USER_IP'");
while($row = mysql_fetch_assoc($sql)){
     echo '<p>'.$row['ip'].' - ['.$row['username'].']</p>';
}

 

What I want to do, though, is only display that if the IP is stored 2+ times in the DB, that way it only displays people with multiple accounts(same IP)

$sql = mysql_query("SELECT * FROM users WHERE ip = '$USER_IP'");
if(mysql_num_rows($sql) > 1){
     while($row = mysql_fetch_assoc($sql)){
          echo '<p>'.$row['ip'].' - ['.$row['username'].']</p>';
     }
}

$sql = mysql_query("SELECT * FROM users WHERE ip = '$USER_IP'");
if(mysql_num_rows($sql) > 1){
     while($row = mysql_fetch_assoc($sql)){
          echo '<p>'.$row['ip'].' - ['.$row['username'].']</p>';
     }
}

 

Sorry for the late reply, this will not work either because what is $USER_IP defined as? A player's IP? I want it to go through the entire players database, and if their are duplicate IP's - than display them. Thank you for the help, though. And if I am wrong, please correct me on how the code above finds dupe IP's in a table.

$USER_IP is a variable that you would define before your query.

 

http://www.php.net/manual/en/reserved.variables.server.php

$USER_IP = $_SERVER['REMOTE_ADDR'];
$sql = mysql_query("SELECT * FROM users WHERE ip = '$USER_IP'");
if(mysql_num_rows($sql) > 1){
     while($row = mysql_fetch_assoc($sql)){
          echo '<p>'.$row['ip'].' - ['.$row['username'].']</p>';
     }
}

$whoinfo = mysql_fetch_array(mysql_query("SELECT ipadd, browser FROM users WHERE id='".$id."'"));
$sql = "SELECT id, name, ipadd FROM users WHERE ipadd='".$whoinfo[0]."' AND browser='".$whoinfo[1]."' ORDER BY name ";
$items = mysql_query($sql);

    if(mysql_num_rows($items)>0)
    {
    while ($item = mysql_fetch_array($items))
    {
      echo "$items[1] - $items[2]<br/>";  // Lists all dummy profiles (if you remove browser then users of same ip)  njoy! 
    }
    }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.