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.
Best,

Karl


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
 0..9.

 $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.

Beckman
---------------------------------------------------------------------- ----- Peter Beckman Internet Guy beck...@angryox.com http:// www.angryox.com/ ---------------------------------------------------------------------- -----

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Karl DeSaulniers
Design Drumm
http://designdrumm.com

Reply via email to