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
https://forums.phpfreaks.com/topic/181462-whats-wrong-with-this-query/
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?

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?

Archived

This topic is now archived and is closed to further replies.

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