slyte33 Posted March 3, 2010 Share Posted March 3, 2010 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 Link to comment https://forums.phpfreaks.com/topic/193968-displaying-multiple-ip-addressstored-in-db-if-more-than-1-of-same-ip/ Share on other sites More sharing options...
The Little Guy Posted March 3, 2010 Share Posted March 3, 2010 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>'; } Link to comment https://forums.phpfreaks.com/topic/193968-displaying-multiple-ip-addressstored-in-db-if-more-than-1-of-same-ip/#findComment-1020774 Share on other sites More sharing options...
slyte33 Posted March 3, 2010 Author Share Posted March 3, 2010 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) Link to comment https://forums.phpfreaks.com/topic/193968-displaying-multiple-ip-addressstored-in-db-if-more-than-1-of-same-ip/#findComment-1020775 Share on other sites More sharing options...
The Little Guy Posted March 3, 2010 Share Posted March 3, 2010 $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>'; } } Link to comment https://forums.phpfreaks.com/topic/193968-displaying-multiple-ip-addressstored-in-db-if-more-than-1-of-same-ip/#findComment-1020777 Share on other sites More sharing options...
slyte33 Posted March 4, 2010 Author Share Posted March 4, 2010 $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. Link to comment https://forums.phpfreaks.com/topic/193968-displaying-multiple-ip-addressstored-in-db-if-more-than-1-of-same-ip/#findComment-1021230 Share on other sites More sharing options...
The Little Guy Posted March 4, 2010 Share Posted March 4, 2010 $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>'; } } Link to comment https://forums.phpfreaks.com/topic/193968-displaying-multiple-ip-addressstored-in-db-if-more-than-1-of-same-ip/#findComment-1021264 Share on other sites More sharing options...
inversesoft123 Posted March 4, 2010 Share Posted March 4, 2010 $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! } } Link to comment https://forums.phpfreaks.com/topic/193968-displaying-multiple-ip-addressstored-in-db-if-more-than-1-of-same-ip/#findComment-1021285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.