papillonstudios Posted November 5, 2011 Share Posted November 5, 2011 I am trying to check for an admin user to access the admin panel. I have been playing around try different things and this what I have ended up with in my database table I have a column called usergroup and i do the follow to check for admin user. $checkAdmin = mysql_query("SELECT * FROM `users` WHERE email='$email' , usergroup = 'admin'"); $adminUser = mysql_num_rows($checkAdmin); if ($adminUser == 0) { echo count($adminUser); die ('You do not have permissions to access this area'); } I do the select statement through phpmyadmin and it comes back with one row. which is basically hat i want to check for. I do have a variable called $email which is getting a value from the email cookie. currently $adminUser Return a value of 10. All of the count() functions is for testing purposes only. Quote Link to comment https://forums.phpfreaks.com/topic/250493-checking-for-admin-user/ Share on other sites More sharing options...
freelance84 Posted November 5, 2011 Share Posted November 5, 2011 Ok, so if it all works what is the problem? Quote Link to comment https://forums.phpfreaks.com/topic/250493-checking-for-admin-user/#findComment-1285236 Share on other sites More sharing options...
floridaflatlander Posted November 5, 2011 Share Posted November 5, 2011 $adminUser = mysql_num_rows($checkAdmin); Are there 10 users listed as admin? Quote Link to comment https://forums.phpfreaks.com/topic/250493-checking-for-admin-user/#findComment-1285242 Share on other sites More sharing options...
papillonstudios Posted November 6, 2011 Author Share Posted November 6, 2011 thats the thing I only have 2 accounts in the database one admin and one user Quote Link to comment https://forums.phpfreaks.com/topic/250493-checking-for-admin-user/#findComment-1285427 Share on other sites More sharing options...
PFMaBiSmAd Posted November 6, 2011 Share Posted November 6, 2011 The WHERE clause in the query you posted is invalid (you probably want to use a logical AND between the two terms) and produces an mysql syntax error. It's impossible that the query/php code you posted is returning 10 for $adminUser. Also, since $adminUser is not an array, using count() on it makes no sense. Quote Link to comment https://forums.phpfreaks.com/topic/250493-checking-for-admin-user/#findComment-1285428 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.