[EMAIL PROTECTED] wrote:

Chris Hewitt <[EMAIL PROTECTED]> wrote:

Warning: undefined constant 'general_user_attrs' used as general_user_attrs in /var/www/html/dialup_admin/htdocs/user_new.php3 line 12

The constant general_user_attrs is a user-defined parameter defined in the .conf file for the application. The .conf file is read in by a php function that stores all parameters in an array called $config. This array is referenced in php files throughout the application tree.

It *appears* that $config is not being passed by php to all the separate files. Do I have to manually configure php to do this? Or is the problem something else altogether? This application (dialup_admin) is not a beta, rather is in general use. I am using Red Hat 7.2, PHP 4.0.6, Apache 1.3.20.


How are you passing $config from file to file? (You do not show us what is in line 12 or the first occurance of $config in the file). It either needs to be in a $_SESSION variable or you application needs register_globals turned on in php.ini.

HTH
Chris

Thanks for your reply. I didn't write dialup_admin and I know little about php, so I am only assuming the app is written correctly.

Yes, register_globals is turned on in php.ini by default. I don't know how $config is passed from file to file; that is part of my problem. I am assuming it is a global and that php recognizes it as such. The .conf file gives me the option of using sessions; I think I have tried it both ways with no good results.

The file user_new.php3 contains the following lines:

require('../conf/config.php3'); #This is the file that reads admin.conf and puts its 
parameters into the $config array
require('../lib/defaults.php3'); #This file references $config

The file ../lib/defaults.php3 looks like this:

<?php
$ARR=file("$config[general_default_file]");
.
.
.
if (is_file("../lib/$config[general_lib_type]/defaults.php3"))
       include("../lib/$config[general_lib_type]defaults.php3"));

Php doesn't like general_lib_type in these lines, referring to it as an undefined constant even though it is set in the .conf file. BTW, this code works if I replace $config[general_lib_type] with the actual subdirectory where defaults.php3 lives. Doing this, however, just causes me to have more warnings further down the application tree.

Any thoughts or ideas would be helpful.

According to the manual, constants should be OK as you have them. Unfortunately, I have little experience of using constants (and I did not get them to work quite as expected when I did). If I get time over the weekend I'll have a play and see what happens and report back.

Regards

Chris

Reply via email to