4 Replies - 265 Views - Last Post: 02 December 2013 - 12:44 PM Rate Topic: -----

#1 Destr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-December 13

Online Users Help

Posted 02 December 2013 - 02:58 AM

Hello everyone I am having a problem trying to count how many registered users are online and was wondering if you could help me I asked one of my friends for this script
$file = "users.ini";

$ip = $_SERVER["REMOTE_ADDR"];

$time = time();

$content = @file_get_contents($file);

$new_content = $ip." = ".$time;

$content .= $new_content."\r\n";

$user = @file_put_contents($file,$content);

$user = @parse_ini_file($file);

$count = 0;

foreach($user as $ip=>$time) {

    if($time >= time() - 300){ // past 3 minutes
    if($count > 10);
    echo "<span></span><span></span><span></span>";
    
    
    
    if($count < $count);
    echo "<span class='ss' id='after'>";

        $count++;

    }

}



Is This A Good Question/Topic? 0
  • +

Replies To: Online Users Help

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5958
  • View blog
  • Posts: 23,226
  • Joined: 23-August 08

Re: Online Users Help

Posted 02 December 2013 - 03:21 AM

You need to specific as to what the problems are, but there are these...

Putting a semi-colon (;) directly after an if like this:

if($count > 10);


makes the if a "no-op"; that is it's making the if useless.

if($count < $count);

How can $count ever be less than itself?
Was This Post Helpful? 1
  • +
  • -

#3 Destr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-December 13

Re: Online Users Help

Posted 02 December 2013 - 03:30 AM

I am getting this error Invalid argument supplied for foreach()
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3397
  • View blog
  • Posts: 9,609
  • Joined: 08-June 10

Re: Online Users Help

Posted 02 December 2013 - 09:49 AM

then, according to the Manual entry, parse_ini_file() must have encountered an error and returned false.
Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

Re: Online Users Help

Posted 02 December 2013 - 12:44 PM

Also note that the @ symbol suppresses warnings/errors. That's the last thing you want to do when debugging.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1