Yes, $req_user_level is an int between 0 and 9.

Yes, the other code worked great.
Thank you for your response though.
That is definitely a good way to cross check.
Thanks again for your responses.


On Jan 25, 2010, at 2:24 PM, Peter Beckman wrote:

On Mon, 25 Jan 2010, Karl DeSaulniers wrote:

Thank you for this as well.
Question? What part is "in_array" playing?
Is it comparing $req_user_level to array()?
Because the text "Guest", etc.. is not in $req_user_level on the database. In other words, is it checking the value of $req_user_level to see if "Guest" is in it?

Sorry, I missed the question mark. in_array isn't appropriate here. The previous poster has it right, assuming $req_user_level is an integer of

 $levels = array("Guest", "Regular User", 'Intl. User', ...)
 // the array is   0    ,      1        ,       2     , ...)

 Going a little further:

if (!empty($levels[$req_user_level])) { // is both set and doesn't evaluate to false
        echo "The user is a {$levels[$req_user_level]}.\n";
    } else {
        //  The $req_user_level was not a valid level.
        echo "The returned req_user_level was not valid.\n";

 Which would output, if $req_user_level was 1 (one):

    The user is a Regular User.

Then you know you have a valid user level. Careful though -- sometimes 0
 will be returned on a failure, depending on your SQL.

---------------------------------------------------------------------- ----- Peter Beckman Internet Guy http:// ---------------------------------------------------------------------- -----

PHP Database Mailing List (
To unsubscribe, visit:

Karl DeSaulniers
Design Drumm

Reply via email to