I cannot figure out why I could be having these problems. I've searched; oh yes, I've searched; and only one other person on the entire Net seems to have had my problem -- and he never received an answer.

I include a file:

requre('config.inc.php');

which contains these constant definitions:

define('ARCH_NO_AUTH', 0);
define('ARCH_AUTH', 1);
define('ARCH_ALREADY_AUTH', 2);
define('ARCH_NO_USER', 3);
define('ARCH_BAD_PASS', 4);
define('ARCH_ANONYMOUS', 5);

I've quoted them properly and everything, as far as I can see. Then I use those constants in a class in another require()d file (I call it 'include/archivosCommonClasses.php'), like so:

$this->authenticatedState = ARCH_NO_AUTH;

All kosher, right? No!
I receive these following errors:

Notice: Use of undefined constant ARCH_NO_AUTH - assumed 'ARCH_NO_AUTH' in /var/www/localhost/htdocs/archivos/include/archivosCommonClasses.inc.php on line 949

As you can see, I'm not falling prey to the usual problem that causes those error messagse (i.e., forgetting to put array indexes in quotes). Another weird thing is that when I take those constant definitions and place them directly in my file (instead of 'config.inc.php') everything works beautifully, and I receive no 'Constant ARCH_NO_AUTH already defined' errors like I'd expect when I define constants in a file and an included file.

Constants from other included files (e.g., constants from ADOD😎 work fine.

any ideas? I'm using PHP 4.3.6 on Linux, if that matters..

    I guess it's probably a typo on the board but you have written requre not require 🙂

      It would appear that CommonClasses.php is being included before config.inc.php.

      Try adding:
      require_once('config.inc.php');
      To the top of CommonClasses.php.

      And maybe toss in an echo in both files just to confirm loading order.

        Inexplicably, ahundiak, that worked. But I still wonder, why on earth would it load all the variable assignments (but not the constant declarations) in config.inc.php when I call it from my page, but work perfectly when I call it from my archivosCommonClasses.php file? weirdness.

        By the way, Shrike, it was a typo on the board. Here's what it looks like in my page:

        require('config.inc.php');
        require($smartyDir . '/Smarty.class.php');
        require($adodbDir . '/adodb.inc.php');
        require($config['tackleDir'] . '/tackle.inc');
        require('include/archivosCommonClasses.inc.php');

        Incidentally, note that the config file is included before the class file.

        Weird stuff.

        Eventually what I settled for was to declare the constants at the beginning of archivosCommonClasses, because I realised that these are, after all, constants... they don't change like the other items in the config file, so they shouldn't be in the config file _

          Write a Reply...