Re: require_once '../config.php'; doesn't work?
| From: | Richard Harb | Date: | Sat, 10 Apr 2004 02:51:21 +0000 |
| Subject: | Re: require_once '../config.php'; doesn't work? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-183049@lists.php.net to get a copy of this message | ||
Depends on where the executed script is located ...
And it always depends on the script that is called - if you give a
relative path like you did here.
if the script you called would be
http://www.example.com/news/2004-04-10/mypage.php
then config.php would have to be in /news
if your layout is like:
/ (root)
|-settings/
|-news/
|-2004-04-10/
and you call a script in root then db.php would be included, but not
if called from the dir news ...
You could either prepend something (like $_SERVER['DOCUMENT_ROOT']) or
you define something like
define ('MY_SETTINGS_DIR', '/usr/local/www/settings');
so the path will be absolute ...
or you could write some function that calculates the relative path to
root no matter where the script you called resides in - and prepend
that string then ...
or ....
hth
Richard
Saturday, April 10, 2004, 4:36:31 AM, you wrote:
> Is it true I can't include a file up a dir like this:
> require_once '../config.php';
> This seems to work though:
> require_once 'settings/db.php';
> Strange.
> ~ Mike
> -----
> Mike Zornek
> Web Designer, Media Developer, Programmer and Geek
> Personal site: <http://MikeZornek.com>
> New Project: <http://WebDevWiki.com>