Friday, November 16, 2012

Server migration problems and php with pear display blank page (PHP Path Problem)

My service provider( linux share hosting ) migrated my website to another server and following problems started
1)
require_once("DB.php"); gives error...
Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in /home/username/public_html/test.php on line 9

Fatal error: require_once() [function.require]: Failed opening required 'DB.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/public_html/test.php on line 9

2)
if you replace require_once("DB.php");
WITH full path...
require_once("/home/username/php/DB.php");
THAN IT DISPLAY BLANK PAGE!!!

Possible Solutions:

1) If your service provider ready to edit php.ini than request them to add PEAR path (most recommended )
2) edit .htaccess file and add
php_value include_path "/yourpath/mywebsite" ( NOT Recommended )
you may have to use ALLOW OVERRIDE 
3) edit your source code and add path
$path = '/home/username/php/';
set_include_path($path . PATH_SEPARATOR . get_include_path()); 

Conclusion:

ALL SHARE HOSTING PROVIDER must co-operate their user and
check all path with php.ini

No comments: