Reputation: 1365
I was using relative paths for all of my PHP includes and locally this worked fine. I just transferred all of my files to the server and I'm getting errors for includes that point to files further up the directory. Ex:
include_once('../db.php');
is giving me:
Warning: include_once(../db.php) [function.include-once]:
failed to open stream: No such file or directory in /nfs/c06/h04/mnt/188388/domains/website.com/html/includes/user_process.php on line 3
I'm not exactly sure what's going on. Any help would be much appreciated.
Upvotes: 1
Views: 46
Reputation: 637
If file is there and access is right, It must be worked
you can try this For include_once a file in every paths of application we can do simply this
include_once($_SERVER["DOCUMENT_ROOT"] . "path/file")
or
<?php
if(!@file_exists('./somthing') ) {
echo 'can not include';
} else {
include('./something');
}
?>
Upvotes: 0
Reputation: 11325
chek if it helps
include_once(dirname(dirname(__FILE__)). '/db.php');
or
include_once(dirname(__DIR__). '/db.php');
Upvotes: 3