Hello, Can someone give me a simple php code where it checks my database row i.e called ip and every users ip is recorded, and if there are any IPs that are the same it will echo/print the IP that is the same. Shouldnt be hard, thanks!
Is this what you want? $visitor_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; $visitor_ip = $_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_X_FORWARDED_FOR']) { $visitor_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $visitor_ip = $_SERVER['REMOTE_ADDR']; } $query = "SELECT ip FROM visitor WHERE ip = '$visitor_ip'"; $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) > 0) { echo "Ip matched in database : $visitor_ip"; } else { echo "This IP is new : $visitor_ip"; } PHP: Or did you meant duplicate ips: $query = "SELECT ip FROM visitor GROUP BY ip"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "Duplicate IP in database : ".$row['ip']."<br />"; } PHP: