Mutley Posted April 8, 2007 Share Posted April 8, 2007 $time = time(); function userOnline($useronline) { // Check if user is online: $result_online = mysql_query("SELECT online FROM users WHERE user_id = '$useronline' LIMIT 1"); while($row_online = mysql_fetch_array( $result_online )) { $online = $row_online['online']; } if($time - $online < 30) { echo "<img src=\"images/online.gif\" alt=\"Online\" /> "; } else { echo "<img src=\"images/offline.gif\" alt=\"Offline\" /> "; } // End check } Then when I use the function it always says there online? However the code works out of function. Link to comment https://forums.phpfreaks.com/topic/46107-function-wont-work/ Share on other sites More sharing options...
esukf Posted April 8, 2007 Share Posted April 8, 2007 $time = time(); needs to be inside your function or you have to use global $time Link to comment https://forums.phpfreaks.com/topic/46107-function-wont-work/#findComment-224040 Share on other sites More sharing options...
Mutley Posted April 8, 2007 Author Share Posted April 8, 2007 Thanks. Fixed. Link to comment https://forums.phpfreaks.com/topic/46107-function-wont-work/#findComment-224041 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.