online users

Discussion in 'PHP' started by cavendano, Mar 10, 2008.

  1. #1
    im having some trouble getting this piece of code to work...
    it is supposed to connect to the database and based on the last time a user did anything on the site it should tell me if they should be considered online or offline.

    Right now the script shows everyone as being offline. I echoed the $online_time and get a result like "20080310104103" but on the mysql table the results are saved as "2008-03-10 10:41:03" is that the reason its not working?
    
    $query = "select * from ".$prefix."access_log WHERE member_id = '$u_id' order by time DESC";
    $result = MySQL_query($query); 
    $rows = @mysql_fetch_array($result);
    $access_time = $rows[time];
    if ($access_time == ""){
    $access_time = date("YmdHis");
    }else{
    $access_time = $rows[time] + 600;
    }
    $online_time = date("YmdHis") + 300;
    if ($user_id == $login){
    $edit = $l_profile_edit;
    }
    if ($access_time > $online_time){
    $stat = "<font color=green>online</font>";
    }else{
    $stat = "<font color=red>offline</font>";
    }
    
    PHP:

     
    cavendano, Mar 10, 2008 IP