Jump to content

What's wrong with this query?


sw0o0sh

Recommended Posts

In this personal forum I am coding I'm trying to grab the users online in the past 5 minutes. Every time a user goes to a new page it updates their "last_movement" field in the SQL database. Here's the query:

 

$i=0;
$sel_users_online = mysql_query("SELECT * FROM rscd_members WHERE last_movement > '" . date("Y-m-d H:i:s", time()-60*5) . "'");
while($grab_d = mysql_fetch_array($sel_users_online)){
echo "<a href='?act=profile&id=".$grab_d['id']."'>" . rank($grab_d['status']) . $grab_d['username'] . "</a>" . (($i < (($total_online) - 1)) ? ", " : null);
$i++;
}

 

Here's an example of an entry stored in last_movement, which is clearly (Y-m-d H:i:s):

 

2009-11-13 23:32:30

 

Can anybody help me out here?

Link to comment
Share on other sites

wat type of field is "last_movement"? datetime?

if so you can change that sql to

$sel_users_online = mysql_query("SELECT * FROM rscd_members WHERE last_movement > NOW() - INTERVAL 5 MINUTE");

 

wat error are you getting? its just not selecting any members?

Link to comment
Share on other sites

wat type of field is "last_movement"? datetime?

if so you can change that sql to

$sel_users_online = mysql_query("SELECT * FROM rscd_members WHERE last_movement > NOW() - INTERVAL 5 MINUTE");

 

wat error are you getting? its just not selecting any members?

 

 

Yeah, it's simply just not selecting any members. It's field_type is "TIMESTAMP", however I tried your method and it seems to work fine :)

 

Is there anywhere I can read a manual on further working with the INTERVAL XX XX type thing?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.