Jump to content
MakeWebGames

Recommended Posts

Posted

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 .

Posted

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

Posted (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 />";
}
?>

help.PNG.68d9df561c3636966f34a9ff19e35d6a.PNG

Edited by Hybridd
Posted
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.

Posted
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

Posted

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>

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