I have Folder Home with two subfolders like the following
+Home
+include
- membersite_config.php
+iDiscover
-index.php
in index.php I added the require_once script to access membersite_config.php
<?PHP
require_once($_SERVER['DOCUMENT_ROOT'].'/include/membersite_config.php');
?>
I get the following error :
Warning: require_once(./include/fg_membersite.php): failed to open stream: No such file or directory in D:\Home\include\membersite_config.php on line 2
Fatal error: require_once(): Failed opening required './include/fg_membersite.php' (include_path='.;C:\php\pear') in D:\Home\include\membersite_config.php on line 2
The error says No such file or directory while the The path "D:\Home\include\membersite_config.php" is correct . When I move index.php to be under the root , the page works well.
I also tried to use the following code as described here but it gives the same error
<?PHP
define('ROOT', 'D:Home\\');
require_once(ROOT ."/include/membersite_config.php");
?>
Edit :
I too tried require_once("../include/membersite_config.php"); And it gives the same error
Thanks in advance
You must include like this
require_once(dirname(__FILE__) . '/include/membersite_config.php');
Because DocumentRoot can be not set in httpd.conf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With