Hybridd Posted August 30, 2014 Share Posted August 30, 2014 before i ask, im not a pro coder im just a beginner trying to learn more. im trying to put users online on the login page but i cant get it to run the script without logging in. so if anyone could help then it would be much appreciated . Quote Link to comment Share on other sites More sharing options...
Script47 Posted August 30, 2014 Share Posted August 30, 2014 Make sure any files you're including aren't blocking users from viewing the page. Quote Link to comment Share on other sites More sharing options...
Hybridd Posted August 30, 2014 Author Share Posted August 30, 2014 iv looked at that but its not working. if u could give me the code for it that u think would work then it would be really helpful. thanks Quote Link to comment Share on other sites More sharing options...
G7470 Posted August 30, 2014 Share Posted August 30, 2014 Agreed with Script47, make sure any files you're including aren't restricting visitors from viewing your page. Can you view the login page without having the users online portion of your code there? ~G7470 Quote Link to comment Share on other sites More sharing options...
Hybridd Posted August 31, 2014 Author Share Posted August 31, 2014 (edited) okay i fixed it now i get an error this is my code <?php $cn=0; $q=$db->query("SELECT * FROM users WHERE laston>unix_timestamp()-15*60 ORDER BY laston DESC"); while($r=$db->fetch_row($q)) { $la=time()-$r['laston']; $unit="secs"; if($la >= 60) { $la=(int) ($la/60); $unit="mins"; } if($la >= 60) { $la=(int) ($la/60); $unit="hours"; if($la >= 24) { $la=(int) ($la/24); $unit="days"; } } $cn++; print "$cn. <a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> ($la $unit)<br />"; } ?> Edited September 1, 2014 by Hybridd Quote Link to comment Share on other sites More sharing options...
SRB Posted August 31, 2014 Share Posted August 31, 2014 okay i fixed it now i get an error, ill show u [ATTACH=CONFIG]1631[/ATTACH] this is my code <?php $cn=0; $q=$db->query("SELECT * FROM users WHERE laston>unix_timestamp()-15*60 ORDER BY laston DESC"); while($r=$db->fetch_row($q)) { $la=time()-$r['laston']; $unit="secs"; if($la >= 60) { $la=(int) ($la/60); $unit="mins"; } if($la >= 60) { $la=(int) ($la/60); $unit="hours"; if($la >= 24) { $la=(int) ($la/24); $unit="days"; } } $cn++; print "$cn. <a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> ($la $unit)<br />"; } ?> include_once('globals_nonauth.php'); If you don't have that file, it looks like you need a database connection file writing and added in. Luckily, you should have it. Quote Link to comment Share on other sites More sharing options...
Hybridd Posted August 31, 2014 Author Share Posted August 31, 2014 include_once('globals_nonauth.php'); If you don't have that file, it looks like you need a database connection file writing and added in. Luckily, you should have it. still getting same error mate Quote Link to comment Share on other sites More sharing options...
Zettieee Posted August 31, 2014 Share Posted August 31, 2014 Post the whole file. Quote Link to comment Share on other sites More sharing options...
Hybridd Posted September 1, 2014 Author Share Posted September 1, 2014 if someone could re code it for me then it would be great and helpful. this is what im using now but it doesnt show the users online it shows this... Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in /home/*****/public_html/login.php on line 109 <div class="box-header"><font color="#00B2FF">Players Online</font></div> <div class="box-center-text"> <?php while($r=mysql_fetch_assoc($q)) { $la=time()-$r['laston']; $unit="secs"; if($la >= 60) { $la=(int) ($la/60); $unit="mins"; } if($la >= 60) { $la=(int) ($la/60); $unit="hours"; if($la >= 24) { $la=(int) ($la/24); $unit="days"; } } $cn++; $name=$r['username']; $id=$r['userid']; $gangtag=$r['yourgangPREF']; if($r['donatordays'] > 0) { $donator="<img src='images/donator.gif' width='15px' height='15' alt='Donator: {$r['donatordays']} Days Left' title='Donator: {$r['donatordays']} Days Left' />"; } if($r['donatordays'] == 0) { $donator=""; } if($r['user_level']== 2) { $staff="Administrator"; } if($r['user_level']== 3) { $staff="Secretary"; } if($r['user_level']== 4) { $staff="Assistant"; } if($r['user_level']== 5) { $staff="Moderator"; } if($r['user_level']== 1) { $staff="Member"; } if($r['donatordays'] > 0) { $donator="<img src='images/donator.gif' width='15px' height='15' alt='Donator: {$r['donatordays']} Days Left' title='Donator: {$r['donatordays']} Days Left' />"; } if($r['donatordays'] == 0) { $donator=""; } if($r['user_level']== 2) { $name="<font color=red>$name</font>"; } if($r['user_level']== 3) { $name="<font color=purple>$name</font>"; } if($r['user_level']== 4) { $name="<font color=green>$name</font>"; } if($r['user_level']== 5) { $name="<font color=blue>$name</font>"; } if($r['user_level']== 1) { $name="<font>$name</font>"; } if($r['donatordays'] > 0 & $r['user_level']== 1) { $name="<font color=cyan>$name</font>"; } $r['username']="<a href='viewuser.php?u={$r['userid']}'>$name $donator [$id]</a> | <b>$staff</b>"; print "<tr style='background:gray'> <td><center>$cn.</center></td> <td><center>Level: {$r['level']}</center></td> <td><center>{$r['username']}</center></td>"; print "</td> <td><center>($la $unit)</center></td>"; $lb=time()-$r['last_login']; $units="secs"; if($lb >= 60) { $lb=(int) ($lb/60); $units="mins"; } if($lb >= 60) { $lb=(int) ($lb/60); $units="hours"; if($lb >= 24) { $lb=(int) ($lb/24); $units="days"; } } if($r['laston'] <= time()-60*60) { $lb="Offline"; $unit=""; } print"</tr>"; } ?> </td> </tr> </table><hr /> <?php ?> </div> </div> Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted September 1, 2014 Share Posted September 1, 2014 Well what is the $q query? Quote Link to comment Share on other sites More sharing options...
Hybridd Posted September 2, 2014 Author Share Posted September 2, 2014 Well what is the $q query? lol no idea, could u not re code it for me? would make my life a lot easier haha 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.