Re: use of undefined constant

From: Date: Thu, 26 Oct 2006 08:06:51 +0000
Subject: Re: use of undefined constant
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-42599@lists.php.net to get a copy of this message
Zbigniew Szalbot wrote:
Hello again, On Thu, 26 Oct 2006, Chris wrote:
In the error log I can see this: Use of undefined constant is_admin - assumed 'is_admin' in /path_to_file.
I bet you have something like: $GLOBALS[is_admin] You need quotes around that, or else (as you've seen) php thinks it's a constant: $GLOBALS['is_admin'] A really quick and dodgy fix would be to turn error reporting down - but you should fix it properly.
That fixed the error. Thank you very much! I am still not able to log in. I am sure this is not the issue of me entering wrong login/password. This is the code in the program that uses authorization: if ( eregi('/admin/',$REQUEST_URI) || eregi('/workers/',$REQUEST_URI) ) {
    session_register("id_worker");
    session_register("is_admin");
    if(!isset($PHP_AUTH_USER) || !$id_worker=getWorkerID($PHP_AUTH_USER, $PHP_AUTH_PW))
    {
        Header( "WWW-authenticate: basic realm='Workers of SGM only'");
        Header( "HTTP/1.0  401  Unauthorized");
        echo  "You  must  enter  a  valid  login  ID  and password  to  access  this system\n";
        exit;
    }
}
You'll need to change: $PHP_AUTH_USER to $_SERVER['PHP_AUTH_USER'] and $PHP_AUTH_PW to $_SERVER['PHP_AUTH_PW'] The former variables are ok before 4.2.0 (where register_globals was off by default I think) but now they have moved to the $_SERVER super-global. Read http://www.php.net/manual/en/language.variables.predefined.php -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.db (#42599) next »