Page 1 of 1

PHP scripting error after changing servers

Posted: Mon Nov 16, 2009 10:39 am
by ejames13
I recently moved a PHP website from one web server to another (changed hosting companies). The site is now hosted with GoDaddy, but when I browse to the hyperlink I receive the following error(s):

Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in /home/content/00/5180700/html/cms/includes/global.inc.php on line 3

Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.:/usr/local/php5/lib/php') in /home/content/00/5180700/html/cms/includes/global.inc.php on line 3

I've spoken with GoDaddy and they assure me it is a problem with the PHP code and not their web server. Please help!

-Eric J

Re: PHP scripting error after changing servers

Posted: Mon Nov 16, 2009 2:48 pm
by requinix
include and require proceed according to the current working directory. This is not always the same directory of the currently-executing script.

If /a.php includes /folder/b.php, and b.php includes "c.php", it will look for /c.php, not /folder/c.php.

The most common solution is to use absolute paths like

Code: Select all

include $_SERVER["DOCUMENT_ROOT"] . "/folder/c.php";
That will work regardless of which file is doing the include().