problem with showing online users
i have a couple of problems. first one is i get this error testing my whoischeck.php
2014-01-22 15:41:42No database selectedNo database selectedNo database selected
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/webim028/public_html/SolaDB/whoischeck.php on line 32
second problem:
there was no session for my user email. so i created $_SESSION['SecurityAssist_UserEmail'];
with security assist i added the update records for both login and logout using the new session i made, but everytime i log in it does not update my table.
code for the whoischeck.php
<?php require_once('Connections/announcement.php'); ?>
<?php require_once('webassist/security_assist/helper_php.php'); ?>
<?php
////// To update session status for user table to get who is online ////////
if(WA_Auth_RulePasses("Logged in to pcms2_users")){ // Begin Show Region
$tm=date("Y-m-d H:i:s");
$xses=$_SESSION['SecurityAssist_UserEmail'];
$q=mysql_query("update pcms2_users set connected_usr='Y', tm_usr='$tm' where UserEmail='$xses'");
echo $tm;
echo mysql_error();}
else{
}
///// ////////////// End of updating login status for who is online ///////
// Find out who is online /////////
$gap=10; // change this to change the time in minutes, This is the time for which active users are collected.
$tm=date ("Y-m-d H:i:s", mktime (date("H"),date("i")-$gap,date("s"),date("m"),date("d"),date("Y")));
//// Let us update the table and set the status to OFF
////for the users who have not interacted with
////pages in last 10 minutes ( set by $gap variable above ) ///
$ut=mysql_query("update pcms2_users set connected_usr='N' where tm_usr < '$tm'");
echo mysql_error();
/// Now let us collect the userEmail from table who are online ////////
$qt=mysql_query("select UserEmail from pcms2_users where tm_usr > '$tm' and connected_usr='Y'");
echo mysql_error();
while($nt=mysql_fetch_array($qt)){
}
?>