Jump to content
MakeWebGames

Function not working


Cronic

Recommended Posts

Hi there,

I'm working on a function that displays the users that are online at the forum page.. That does work so far...

 

<div id="right_c">
<div class="g_content">
<h3>  Mobsters Currently Browsing Forum</h3>
<div class="g_text">
<table width="100%">
<tr>
<td align="15%"><?php users_browsing_forum() ?></td>
</tr>
</table>
</div>
</div>
</div>

 

Now i'm trying to get it when users are over 15 minutes last active, they will be automatic removed from the Users Browsing Forum List

This is the function:

function users_browsing_forum(){
$result = mysql_query("SELECT userid FROM forum_browsers");
while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
   $forum_user = new User($line['userid']);
echo "$forum_user->formattedname, ";
}
if (time() - $forum_user->lastactive > 900) {
	$result = mysql_query("DELETE FROM `forum_browsers` WHERE `id`='$forum_user->id'");

}
}

 

So I created another test account and changed the last active days through database to:

Last Active: 2546d 7h 28m 11s

Visit the forums again, and it still looks like this

Mobsters Currently Browsing Forum

forum test, [MH] ~ Admin,

This is how the mysql table looks like

CREATE TABLE IF NOT EXISTS `forum_browsers` (
 `id` int(200) NOT NULL AUTO_INCREMENT,
 `userid` int(200) NOT NULL,
 `name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
 `age` int(50) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=0 ;

 

Does anyone know what i'm doing wrong?

Link to comment
Share on other sites

lastactive is going to pull the online time not the one on the forum table unless you have defined it so on classes!

Meaning that whenever you make a "new User()" the lastactive will be defined as it is on User() class!

$this->lastactive = $worked['lastactive'];

so you need either to add a new line on the classes let's say $this->activeforum and need to add the query previously to the call, or make the sql's directly in the function

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...