Zoofu Posted January 20, 2010 Share Posted January 20, 2010 Im trying to track how many IP's are online. And it's not exactly working. -.- (Not inserting). if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $CIP=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $CIP=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $CIP=$_SERVER['REMOTE_ADDR']; } $selv300=mysql_query("SELECT * FROM `online` WHERE `ip`='$CIP'") OR die(mysql_error()); $rowv300=mysql_fetch_assoc($selv300); if($rowv300){ }else{ $sql400 = "INSERT INTO `online` (`ip`) VALUES ('".$CIP."')"; $res400 = mysql_query($sql400) or die(mysql_error()); } * - * - Edit! It only works when the user is logged in for some reason, but even if they aren't online, I can still echo out their IP. Link to comment https://forums.phpfreaks.com/topic/189213-i-am-absolutely-stumped-right-now-ips/ Share on other sites More sharing options...
Zoofu Posted January 20, 2010 Author Share Posted January 20, 2010 I've been trying to fix this for what? a week? I just figured out that 305 lines above this code snippet, there's an opened if($_SESSION['uid']){ god, Im daft. I put it in my if online section. xD Link to comment https://forums.phpfreaks.com/topic/189213-i-am-absolutely-stumped-right-now-ips/#findComment-998908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.