ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!
Home
Upgrade
Credits
Help
Search
Awards
Achievements
 5048

Displaying Users [ERROR]

by Hazeral - 12-18-2016 - 02:19 PM
#1
So I'm trying to display all the users in a table but some of the information only admins can see, this is my code so far, I got no errors when I checked it on phpcodechecker.com but when I go to the page I get an HTTP error 500. This is my code so far.

Code:
<?php
    $res=mysql_query("SELECT * FROM users");
    $userRow=mysql_fetch_array($res);
    
    $you=mysql_query("SELECT * FROM users WHERE userId=".$_SESSION['user']);
    $viewer=mysql_fetch_array($you);
    
    echo '<table>
          <tr>
            <th>Username</th>
            ';
                if ($viewer['userPerm'] == 1) {
                echo '<th>ID</th>
                  <th>Email</th>';
            }
         echo '</tr>';
    while($userRow){
      echo '<tr>
            <td><font size="2" face="Lucida Sans Unicode" color=#000000>'.$userRow['userName'].'</td>
            ';
            if ($viewer['userPerm'] == 1) {
                echo '<td><font size="2" face="Lucida Sans Unicode" color=#000000>'.$userRow['userID'].'</td>
                  <td><font size="2" face="Lucida Sans Unicode" color=#000000>'.$userRow['userEmail'].'</td>';
                }
            echo '</tr>';
    }
    echo '</table>';
?>
Reply
#2
Can a staff member lock this please? I already figured it out.
Reply
#3
Good share. Thanks
Reply
#4
are you sure that you ve connected to mysql server?
Reply

Users browsing: 7 Guest(s)