Tcmaker Posted January 9, 2010 Posted January 9, 2010 i have added this code into my forum to show when people online if($r['laston'] >= time()-15*60) { $on="<img src=onlinee.png>"; } else { $on="<img src=offlinee.png>"; } this is the bit that goes next to code for username {$on} the problem is it just show offline all the while can someone please correct the code for me please Quote
Guest Null Posted January 9, 2010 Posted January 9, 2010 Well.. First of all, You may have a typo in your images. It says onlinee.png and offlinee.png. Dunno if thats correct for your images or not. Second, You should use single quotes after = and before > on the $on and $on ones. Quote
rulerofzu Posted January 10, 2010 Posted January 10, 2010 Doesnt look like there is anything wrong so must be something else that is not working. I use if($r['laston'] >= time()-15*60) { $on="<span style='color: green;'>[b]Online[/b]</span>"; } else { $on="<span style='color: red;'>[b]Offline[/b]</span>"; } which works fine. Quote
bluegman991 Posted January 11, 2010 Posted January 11, 2010 if($r['laston'] >= time()-15*60) { $on="[img=onlinee.png]"; } else { $on="[img=offlinee.png]"; } that should work i changed <img src=onlinee.png> to Quote
AlabamaHit Posted January 11, 2010 Posted January 11, 2010 $on = $r['laston'] >= time()-15*60 ? ("<img scr='online.png' />") : ("<img scr='offlinee.png' />"); Quote
Uridium Posted January 11, 2010 Posted January 11, 2010 $on = $r['laston'] >= time()-15*60 ? ("<img scr='online.png' />") : ("<img scr='offlinee.png' />"); not sure SCR is correct on this one Alabama Unless its a typo.. SRC would be correct Quote
AlabamaHit Posted January 11, 2010 Posted January 11, 2010 lol yeah typo. I'm tryig to find my old keyboard, this new one sucks. I hate the low keys lol Quote
Tcmaker Posted January 12, 2010 Author Posted January 12, 2010 guys there is no typo on images that just what i have called my images for some weird reason both of those show a blank image also this one work with images but doesnt show when the user is actually online if($r['laston'] >= time()-15*60) { $on="<img src=onlinee.png>"; } else { $on="<img src=offlinee.png>"; } Quote
rulerofzu Posted January 12, 2010 Posted January 12, 2010 Then as I said the problem lies elsewhere. Your first call would be to now check the database to see if there is timstamp value for laston when you login. Quote
Tcmaker Posted January 12, 2010 Author Posted January 12, 2010 Then as I said the problem lies elsewhere. Your first call would be to now check the database to see if there is timstamp value for laston when you login. i have this working on mailbox but for some reason not on forums Quote
bluegman991 Posted January 12, 2010 Posted January 12, 2010 this works fine on mysite check to make sure your link to the images is correct then check to make sure your using the right variable and your sql query is correct if($r['laston'] >= time()-15*60) { $on="[img=onlinee.png]"; } else { $on="[img=offlinee.png]"; } Quote
rulerofzu Posted January 19, 2010 Posted January 19, 2010 Oh lol I know what your problem is. look in your forum code for the users query and make sure laston is in the query. $r = $db->fetch_row($db->query("SELECT userid, username, donatordays, posts, display_pic, forums_signature, level, laston FROM users WHERE userid=".$r['fp_poster_id'].")); For example. Quote
CJ - Twitch Posted January 31, 2010 Posted January 31, 2010 if($memb['laston'] >= time()-15*60) { $on="[img=onlinee.png]"; } else { $on="[img=offlinee.png]"; } That should work. You are using this for the forum therefore $r would be $memb .. ;) Quote
CrazyT Posted January 31, 2010 Posted January 31, 2010 $on = $r['laston'] >= time()-15*60 ? ("<img scr='online.png' />") : ("<img scr='offlinee.png' />"); Any need for more code? echo '[img='. ($r['laston'] >= time() - 900 ? 'on' : 'off') .'line.png]'; Would work just fine. Quote
bluegman991 Posted January 31, 2010 Posted January 31, 2010 if this stuff is in a function and the defined variable is outside of the function make sure u have global $r; or global $memb; or whatever ur variable is, somewhere in there also make sure the variable is defined before u call to it if u know this stuff srry if im making it seem like u didnt know it i just dont know why any of this stuff isnt working Quote
Zero-Affect Posted January 31, 2010 Posted January 31, 2010 $on = $r['laston'] >= time()-15*60 ? ("<img scr='online.png' />") : ("<img scr='offlinee.png' />"); Any need for more code? echo '[img='. ($r['laston'] >= time() - 900 ? 'on' : 'off') .'line.png]'; Would work just fine. LazyT's got a point ternary operators ain't only used in variables. Quote
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.