In my Xampp I can do :
require_once('../myFile.php');
And it works.
When I upload the file that do the require_once, it doesn’t work.
Here is the error on the server:
Warning: require_once(../myFile.php) [function.require-once]: failed to open stream: No such file or directory in /home/xxx/public_html/yyyy/testinclude.php on line 11
Fatal error: require_once() [function.require]: Failed opening required '../myFile.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxx/public_html/yyyy/testinclude.php on line 11
Any idea?
One possible reason why its not working is that your file-casing isn’t exactly the same.
In UNIX, file paths are case-sensitive. This is not the case in WIN. So, if you are including
../myFile.php, your file must be namemyFile.php, notmyfile.php.Also,
includeare always including files according to the current path. Consider these two files.When running
first.php, the second file will include/home/xxx/public_html/third.php.When running
dir/second.phpdirectly, it will include/home/xxx/public_html/dir/third.php.If your include must always be relative to the current file, use the following:
Using the above code fragment,
dir/second.phpwill always include/home/xxx/public_html/dir/third.phpregardless of the current directory.