![]() |
Including.. :S
Ye, something's.. wrong >.<
My config.php lies in: website/includes/config.php My admin files lies in: website/admin/*.php It works fine to include the config from there with this: PHP Code:
website/admin/edit/tab.php And I can't seem to include the config file from there :S I tried with: PHP Code:
|
Try a path to the included file
- include '/your/path/to/folder/includes/config.php'; it'll be better if you have one file that includes all other files - your admin.php just includes other needed files - the tab.php file. And then in your admin file you make all the configuration needed to run your site. Or if you have you config file in an array, or if it is an object you can use the global var scope. Here are 2 examples: - array styled config file - object styled config file PHP Code:
PHP Code:
And if you are using functions and you need to access the $config - you use the global variable scope PHP Code:
|
.. goes back one directory so you need to go back two, ../../PHP Code:
. is the same directory. .. is the parent directory. You can put as many of those in there as you need. Separate folders with a / . |
Thanks both of you :-)
I found that wGEric's method worked best for me :-) |
To stop this issue cropping up at all, use $_SERVER['DOCUMENT_ROOT']. This will automatically go to your root dir:)
you'd just put include($_SERVER['DOCUMENT_ROOT']."/website/includes/config.php"); works in any directory |
Quote:
include('/website/includes/config.php'); Still, I didn't want to use this, since I might change the name of the folder of the website, so I needed a path FROM the current folder :-) |
To always reference the path to the file with the
include call in it, you can use the dirname function with an argument using the constant __FILE__, the latter always giving the path to the file it is used in. So used from admin/edit/tab.php: include dirname(__FILE__).'/../../includes/config.php';It might, or might not, prove useful to you. :-) |
Thanks :-D Can be useful, not in this case though, but it's always good to know ;-)
|
| All times are GMT. The time now is 08:38 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0