Possible Duplicate:
include file from different directory
I have a site laid out as follows:
- index.php includes include/code.php
- config.php
- include/
- code.php includes ./config.php
- admin/
- index.php includes code.php
When doing the inclusion from the primary index there are no problems, however when I try and include code.php from admin it fails to locate and include config.php
You have three options that I can think of:
require_once BASE_DIR . '/include/code.php';dirname(__FILE__)to ensure that the relative path is in fact relative to the current file (and not the executed file). For example:require_once dirname(__FILE__) . '/../include/code.php';require_once '/include/code.php';