Irksome Posted September 21, 2007 Share Posted September 21, 2007 Hi all, I'm in the process of making a user management script, and have come to a dead end here. I have the following code for the page that lists the current user accounts registered in the database. <?php session_start(); require "../db.php"; require "../global.php"; switch ($_SESSION['user_level']) { default:echo $text['adminperms']; exit; case 4: case 5: $result = mysql_query("SELECT * FROM com_users WHERE user_level > 4 ORDER BY userid DESC",$connection) or die(mysql_error()); $user_list = "<ul>"; while ($myrow = mysql_fetch_assoc($result)) { $userid = $myrow['userid']; $username = $row['lname']; $user_level = $row['fname']; $user_list .= "<li><a href=\"edit_user.php?userid=$userid\">$username</a>"; } $user_list .= "</ul>"; } ?> The problem is, I'm getting logged out whenever this page is accessed, therefore getting my "No admin permissions" error message. I've tried running this script without the permission requirements, but still no joy, just a blank page. If anyone could point out what's wrong with that code then I would be ever so grateful. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/70124-session-problem/ Share on other sites More sharing options...
d22552000 Posted September 21, 2007 Share Posted September 21, 2007 switch ($_SESSION['user_level']) { default:echo $text['adminperms']; exit; case 4: case 5: should be: switch ($_SESSION['user_level']) { default: echo $text['adminperms']; exit; break; case 4: /* do something */ break; case 5: /* do something */ break; } Every case has to break at the end. Quote Link to comment https://forums.phpfreaks.com/topic/70124-session-problem/#findComment-352181 Share on other sites More sharing options...
Irksome Posted September 21, 2007 Author Share Posted September 21, 2007 Ah how could I have missed that? Seems I'm getting a blank page now though, no errors or anything. Do you know what this could be down to? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/70124-session-problem/#findComment-352182 Share on other sites More sharing options...
AdRock Posted September 21, 2007 Share Posted September 21, 2007 $result = mysql_query("SELECT * FROM com_users WHERE user_level > 4 ORDER BY userid DESC",$connection) or die(mysql_error()); echo"<ul>"; while ($myrow = mysql_fetch_assoc($result)) { $userid = $myrow['userid']; $username = $row['lname']; $user_level = $row['fname']; echo"<li><a href=\"edit_user.php?userid=$userid\">$username</a>"; } echo"</ul>"; Quote Link to comment https://forums.phpfreaks.com/topic/70124-session-problem/#findComment-352368 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.