Trying to query a list of online users.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aIexi
Forum Newbie
Posts: 12
Joined: Wed Mar 16, 2011 10:46 pm

Trying to query a list of online users.

Post by aIexi »

Hello,

I'm creating a game, and I want to show a list of players who have done something to update the timestamp in the past 3 minutes. On every button they click, a time stamp is updated.

Now I want to echo out the page, but my query seems to be wrong. I'm not sure how often it updates, or what it's doing, but it doesn't seem to be working properly.

Code: Select all


$queryu="SELECT * FROM users WHERE lastonline >= DATE_SUB(CURDATE(), INTERVAL 3 MINUTE)";

Can anyone give me any advice on how to correct this?

Thanks,

Alexi
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: Trying to query a list of online users.

Post by fugix »

I assume that you are puting this into the mysql_query() function right?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Trying to query a list of online users.

Post by social_experiment »

An easy way of troubleshooting is to use the following code while you are still in the developing phase/s

Code: Select all

$sql = mysql_query($your_query) or die(mysql_error());
If there is a problem with $your_query it will immediatly show up and you can fix the problem.
aIexi wrote:...but it doesn't seem to be working properly.
Are you receiving any errors, warnings? Be more specific about the problem.
Hth
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply