Reaper0167 Posted July 8, 2009 Share Posted July 8, 2009 I am looking to add the users ip to the hit counter as long it is not one of the two listed in the script. But I can not get this to work. Anyone? <?php include('config.php'); $ip = $_SERVER['REMOTE_ADDR']; $sql = "SELECT id FROM total_homepage_hits WHERE ip = '$ip' LIMIT 1"; $result = mysql_query($sql); $count = mysql_num_rows($result); $check = mysql_fetch_assoc($result); $mark = $check['ip']; if($mark != "***1****" or $mark != "*****2****") { mysql_query("INSERT INTO total_homepage_hits (ip) VALUES ('$ip')"); // add ip to database if it is not one of the two listed in the if statement. } ?> Link to comment https://forums.phpfreaks.com/topic/165274-solved-help-with-hit-counter-script/ Share on other sites More sharing options...
p2grace Posted July 8, 2009 Share Posted July 8, 2009 Change your if statement to this: if($mark != "***1****" && $mark != "*****2****") Link to comment https://forums.phpfreaks.com/topic/165274-solved-help-with-hit-counter-script/#findComment-871574 Share on other sites More sharing options...
Reaper0167 Posted July 8, 2009 Author Share Posted July 8, 2009 still the same problem. Link to comment https://forums.phpfreaks.com/topic/165274-solved-help-with-hit-counter-script/#findComment-871586 Share on other sites More sharing options...
p2grace Posted July 8, 2009 Share Posted July 8, 2009 What exactly is it doing that is wrong. Link to comment https://forums.phpfreaks.com/topic/165274-solved-help-with-hit-counter-script/#findComment-871591 Share on other sites More sharing options...
Reaper0167 Posted July 9, 2009 Author Share Posted July 9, 2009 There are two ip's that I do not want the hit counter to add into the database. But all the other ip's, I want to be inserted in the database. The script I'm having problems with still add my ip to the database. Link to comment https://forums.phpfreaks.com/topic/165274-solved-help-with-hit-counter-script/#findComment-871600 Share on other sites More sharing options...
p2grace Posted July 9, 2009 Share Posted July 9, 2009 Ahh I think I see the issue. You are querying for the id (SELECT id ...) and you're requesting $check['ip'] which doesn't exist (because you didn't query for it). Either update your query, or your if statement so the variables match. Link to comment https://forums.phpfreaks.com/topic/165274-solved-help-with-hit-counter-script/#findComment-871622 Share on other sites More sharing options...
Reaper0167 Posted July 9, 2009 Author Share Posted July 9, 2009 wow, thanks. I feel dumb. but it is fixed. Link to comment https://forums.phpfreaks.com/topic/165274-solved-help-with-hit-counter-script/#findComment-871634 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.