Jump to content


Photo

Session Counter


  • Please log in to reply
No replies to this topic

#1 cmaier

cmaier
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 11 February 2006 - 02:18 AM

I got this script....

  <?php
     session_save_path("/home/content/*/*/*/*****/html/sessions/");
     session_start();
     define("MAX_IDLE_TIME", 3);
     function getOnlineUsers(){
     if ( $directory_handle = opendir( session_save_path() ) )
      {
        $count = 0;
        while ( false !== ( $file = readdir( $directory_handle ) ) )
         {
           if($file != '.' && $file != '..')
            {
              if(time()- fileatime(session_save_path() . '\\' . $file) < MAX_IDLE_TIME * 60)
               {
                 $count++;
               }
            }
           closedir($directory_handle);
           return $count;
         }
         else
         {
           return false;
         }
      }
     echo 'Number of online users: ' . getOnlineUsers() . '<br>';
    ?>

.. from [a href=\"http://www.devarticles.com/c/a/PHP/The-Quickest-Way-To-Count-Users-Online-With-PHP/1/\" target=\"_blank\"]here[/a] and it says it does what i want but i can't get it to run correctly... i keep getting an error on the "else"... i can't figure out why.. i've read through it a bunch and everything that is opened seems to be closed correctly and the else appears to be in the correct location.

The error i get looks like this...

Parse error: parse error, unexpected T_ELSE in /home/content/*/*/*/*****/html/test/index.php on line 149

... where line 149 contains the "else" phrase.

Any ideas? Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users