Jump to content

[SOLVED] Small function problem


graham23s

Recommended Posts

Hi Guys,

 

i have made some small functions to get a users class:

 

     ####################################################################################
     # Get the logged in users class
     ####################################################################################  
     function get_user_class($users_id) {
     
     ## query the db for the users class
     $QUC = "SELECT `user_class` FROM `membership` WHERE `id`='$users_id'";
     $RUC = mysql_query($QUC) or die (mysql_error());
     $R = mysql_fetch_array($RUC) or die (mysql_error());
     
     $class = $R['user_class'];
     
     echo $class;
     
     return;
     
     }
     
     ####################################################################################
     # MOD
     ####################################################################################  
     function MODERATOR() {
     
     echo "Moderator";
     
     return;
     
     }
     
     ####################################################################################
     # MOD
     ####################################################################################  
     function ADMIN() {
     
     echo "Site Administrator";
     
     return;
     
     }

 

when i test it, it displays the classes ok but does show an error if they arent the same!

 

           ## user class
           if(get_user_class($users_id) != MODERATOR()) {
           
           stderr("Error","Your not a moderator!");
           include("includes/footer.php");
           exit;
           
           }

 

can anyone see what went wrong at all?

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/73143-solved-small-function-problem/
Share on other sites

change the second code (you have extra parantheses after the moderator

 

           ## user class
           if(get_user_class($users_id) != "MODERATOR") {
           
           stderr("Error","Your not a moderator!");
           include("includes/footer.php");
           exit;
           
           }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.