Jump to content
MakeWebGames

Recommended Posts

Posted

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

Posted

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.

Posted

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.

Posted
$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

Posted

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>"; }

Posted
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

Posted

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]"; }
Posted

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.

  • 2 weeks later...
Posted
$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.

Posted

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

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

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.   Paste as plain text instead

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