I am trying to get this counter working but for some reason i get an error.
"mysql_result() expects parameter 1 to be resource, boolean given in *\functions\users.php on line 85"
I have an if statement that checks if the user is logged in:
if(logged_in() === true){
$session_user_id = $_SESSION['user_id'];
$user_data = user_data($session_user_id, 'user_id', 'username', 'password');
}
and a function that will update the data base:
function online_user_count(){
mysql_query("UPDATE `users` SET LastTimeSeen = NOW() WHERE `user_id` = " . $_SESSION['user_id']);
return mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE LastTimeSeen > DATE_SUB(NOW(), INTERVAL 5 MINUTE)"), 0);
}
which i then call on my main home page:
<?php echo online_user_count(); ?>
what is wrong?