Forum Moderators: coopster
But of an emergency here. I've changed the A records to point to a new webhosting package with Hostgator and my includes using the code:
<?php include($_SERVER['DOCUMENT_ROOT'] ."/includes/head.inc.php"); ?> This is the error I'm getting
Warning: include(/usr/local/apache/htdocs/includes/head.inc.php) [function.include]: failed to open stream: No such file or directory in /home/username/public_html/index.php on line 1Warning: include() [function.include]: Failed opening '/usr/local/apache/htdocs/includes/head.inc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/public_html/index.php on line 1.......etc.
When I look at phpinfo(), it shows that the path to DOCUMENT_ROOT is '/usr/local/apache/htdocs/' whereas I'm assuming it should be '/home/username/public_html/' right?
Is this something I need my webhost to change, or can I do it myself within something like php.ini?
Thanks,
mn
<?php include '/home/username/public_html/'."includes/head.inc.php" ?>
rocknbil also suggests setting a constant rather than changing the location multiple times, which seems like good advice:
<?php
define("ROOT_PATH","/home/username/public_html/");
include ROOT_PATH . "includes/head.inc.php";
?>
When I look at phpinfo(), it shows that the path to DOCUMENT_ROOT is '/usr/local/apache/htdocs/' whereas I'm assuming it should be '/home/username/public_html/' right?
Shared hosting?
I am guessing this is one of those cases where the document root does not equal your domain root due to the way the hosting is set up. Your actual domain root is probably aliased from somewhere.
The DOCUMENT_ROOT is not a PHP variable, it is a server environment variable, so it's highly unlikely you'll be able to modify it, nor should you want to. The full server path to your actual files, as suggested, is probably the only "fix".