Xeoncross Posted August 28, 2007 Share Posted August 28, 2007 I have a file in an admin area that is not getting access to the $site_config variables in a config file. Here is what my simplified file system looks like: config.php index.php /lang/en.php /admin/index.php When I run index.php in the root dir it reads config.php and finds the file "en.php" in the language folder. Because config has a value called "$site_config["lang"]" which is = "en" so config includes "en.php"; Now when I access /admin/index.php it also reads the config file but it tries to find "/lang/.php" because the variable "$site_config["lang"]" appears to be empty. Here is what /admin/index.php looks like: require("../config.php"); require("../lang/". $site_config["lang"]. '.php'); Anyone know what might be wrong? Why is $site_config["lang"] set to "en" for index.php and not for /admin/index.php? Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 28, 2007 Share Posted August 28, 2007 You should post more code on how you are including each file and where. Quote Link to comment Share on other sites More sharing options...
Xeoncross Posted August 28, 2007 Author Share Posted August 28, 2007 How does php read files? like take the "include" logic bellow. Each of the ">" means that it is requiring the following file: index > functions > config > site_config > lang Would php get to the "config" page run it and then go back to "functions" and include "lang" before it included "site_config"? Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 What? Are you sure config is actually included? And that site_config is? Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 28, 2007 Share Posted August 28, 2007 I think if you posted some code someone would catch something wrong. Quote Link to comment Share on other sites More sharing options...
Xeoncross Posted August 28, 2007 Author Share Posted August 28, 2007 ok, I found the problem - in config.php there is a the code like this: <?php $file = 'sites/site_config.php'; if(file_exists($file)) { require_once($file); } ?> Somehow that code was true on the "/index.php" file but not on "/admin/index.php". Therefore the $site_config array was included on "/index.php" but not on "/admin/index.php". aghhhh.... Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 28, 2007 Share Posted August 28, 2007 Well, the path is not the same anymore. On that page the sites folder exists in the same directory as index.php. In the admin folder there is no sites folder. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.