Lithium Posted January 15, 2009 Share Posted January 15, 2009 A friend asked me for a little change on the users online to show only users active since a certain amount of days... so far so good, though there is 1 user that simply doesn't show. Not even with direct input of the query on phpmyadmin. Let's say the code is as follows SELECT userid FROM users WHERE laston>unix_timestamp()-(1440*24*45) Shows the list on the users active within 45days or less... but 1 player, inactive for 32 days, simply doesn't show! I am pointing to an account problem, but as i have no access to the phpadmin, i'm only guessing. Anyone as any idea on what can cause the problem? Quote Link to comment Share on other sites More sharing options...
Cronus Posted January 15, 2009 Share Posted January 15, 2009 Re: Weird Situation He is obviously a god! Quote Link to comment Share on other sites More sharing options...
POG1 Posted January 15, 2009 Share Posted January 15, 2009 Re: Weird Situation A friend asked me for a little change on the users online to show only users active since a certain amount of days... so far so good, though there is 1 user that simply doesn't show. wouldn't it be something like this.. SELECT * FROM users WHERE laston > (unix_timestamp() - 300) AND days_old > '2' Quote Link to comment Share on other sites More sharing options...
Dazza Posted January 15, 2009 Share Posted January 15, 2009 Re: Weird Situation Does it matter if he isnt displayed? Hes inactive Hes not a NPC or anything or created an account but never logged in? Weird Quote Link to comment Share on other sites More sharing options...
Lithium Posted January 15, 2009 Author Share Posted January 15, 2009 Re: Weird Situation A friend asked me for a little change on the users online to show only users active since a certain amount of days... so far so good, though there is 1 user that simply doesn't show. wouldn't it be something like this.. SELECT * FROM users WHERE laston > (unix_timestamp() - 300) AND days_old > '2' That would only show users that were last online on the last 5 minutes ;) Quote Link to comment Share on other sites More sharing options...
Lithium Posted January 15, 2009 Author Share Posted January 15, 2009 Re: Weird Situation Does it matter if he isnt displayed? Hes inactive Hes not a NPC or anything or created an account but never logged in? Weird Not an NPC and used to be an active player. :| Quote Link to comment Share on other sites More sharing options...
POG1 Posted January 15, 2009 Share Posted January 15, 2009 Re: Weird Situation A friend asked me for a little change on the users online to show only users active since a certain amount of days... so far so good, though there is 1 user that simply doesn't show. wouldn't it be something like this.. SELECT * FROM users WHERE laston > (unix_timestamp() - 300) AND days_old > '2' That would only show users that were last online on the last 5 minutes ;) I thought that was u wanted, it seems like a pretty stupid idea otherwise. $hour = 60*60*24; $howMany = 4; // set the days $stamp = $day * $howMany; 'SELECT * FROM users WHERE laston > (unix_timestamp() - '.$stamp.' )';' Quote Link to comment Share on other sites More sharing options...
Lithium Posted January 15, 2009 Author Share Posted January 15, 2009 Re: Weird Situation @POG using select * is not an option ;) as you should call things by their names as best practices say, also, if you read my post, i have no trouble making users to show up, only 1 specific user that is within the range for the SELECT, is not showing, not even placing the SELECT directly on the DB., but thx for the effort though :) Quote Link to comment Share on other sites More sharing options...
POG1 Posted January 15, 2009 Share Posted January 15, 2009 Re: Weird Situation ... within the range for the SELECT, is not showing, not even placing the SELECT directly on the DB., but thx for the effort though :) ay? Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted January 16, 2009 Share Posted January 16, 2009 Re: Weird Situation i think POG was pointing you in direction........He was showing a way to try to see if taht 1 user shows with that code.......of course change the * to whatever fields your using...hes not coding your game, lol...Just helping :-P Quote Link to comment Share on other sites More sharing options...
Lithium Posted January 16, 2009 Author Share Posted January 16, 2009 Re: Weird Situation An update... laston value = 1229278774 SELECT userid FROM users WHERE laston > unix_timestamp()-(1440*24*amount_of_days) AND userid=XXX Tends to NOT showing any results, up to 81 days, at 82 it gives a result as expected... SELECT laston, unix_timestamp( ) - (1440 *24 *amount_of_days) FROM users WHERE userid=XXX also shows the correct timestamped values! Quote Link to comment Share on other sites More sharing options...
Lithium Posted January 16, 2009 Author Share Posted January 16, 2009 Re: Weird Situation Seems i messed up calculating the seconds, though no one noticed it too. Thanks everyone that somehow tried to give an hand to it. SELECT userid FROM users WHERE (unix_timestamp() - laston) <= 86400*45 86400 = total seconds in a day 45 = days you want to get If you want to show active users for a certain period only, just replace the 1st query on userlist for a query like that and you're done! Once again thx :) Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted January 16, 2009 Share Posted January 16, 2009 Re: Weird Situation no one was checking stufrf like taht cause you said it worked perfect except for one Person....... But I'm glad you got it working. Quote Link to comment Share on other sites More sharing options...
Lithium Posted January 16, 2009 Author Share Posted January 16, 2009 Re: Weird Situation no one was checking stufrf like taht cause you said it worked perfect except for one Person....... But I'm glad you got it working. One of those things that makes me angry with myself, lol !!! a few hours looking at it, a couple of persons also looked, no one noticed the bad math! out of the box, a pair of fresh eyes note the error on the spot! Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted January 16, 2009 Share Posted January 16, 2009 Re: Weird Situation i ahve done that numerous times, lol. Look for hours and find out it was just i misspelled a word, lol.. like if($ir['usernmae']) and get no error, just not working, lol...and hours go by before i notice it, lol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.