Here is a little breakdown of whats going on
The biggest problem I have right now is, in login.php, it is supposed to change a flag in the database to show a person is online.
if($table=='chatmodels'){
$sql="update ".$table." set loginStatus=1 where user=".$id['user'];
$upd=mysql_query($sql);
It should change 'chatmodels.loginStatus' to equal 1 once a person successfully logs in, but it doesn't work. It used to work.
I'm pretty sure the I have something wrong in the database configuration.
Here is a screenshot of my database http://i.stack.imgur.com/BcaII.jpg
From the screen shot, I see that the chatmodels
table resides in the qoc1
database.
Since you are using php, you need to do one of two things:
Option 1 : Use mysql_select_db as follows:
mysql_select_db('qoc1');
before calling for the update query
if($table=='chatmodels'){
mysql_select_db('qoc1');
$sql="update ".$table." set loginStatus=1 where user=".$id['user'];
$upd=mysql_query($sql);
Option 2 : Put qoc1
into the query itself:
if($table=='chatmodels'){
$sql="update qoc1.".$table." set loginStatus=1 where user=".$id['user'];
$upd=mysql_query($sql);
Give it a Try !!!
Other things to remember
UPDATE 2011-12-15 15:28 EDT
Try putting 'or die'
after the $upd=mysql_query($sql);
and see what mysql-based error message comes back
You've already got advice that should help you solve this problem, but what about the problem of when sessions expire? If loginStatus==1
, is there a cron job or something external to what you've posted that turns it back to 0 for inactive users?
I think a better way to achieve the same result would be to have each page load commit a "lastSeen" timestamp. Then your list of "online" users consists of everyone whose "lastSeen" is within a configurable or programmable period, rather than those folks whose flag has not yet been reset to 0.