DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   open_basedir restriction in effect error in PHP (http://www.daniweb.com/forums/thread110792.html)

BenR41 Feb 25th, 2008 10:29 am
open_basedir restriction in effect error in PHP
 
This must be one of the most annoying errors to get when working with php. This error occurs when PHP can't find the specified file in the include statement. This often occurs when a developer has built an application on their machine and uploaded the application to a shared hosting account or if they move the application to a sub folder.

An easy work around is to determine the path to the called file dynamically.
$folcnt = substr_count($_SERVER["PHP_SELF"], "/");
$folappstep = "";
if($folcnt > 1) {
 for($i=2;$i<=$folcnt;$i++) {
  $folappstep .= "../";
 }
} else {
 $folappstep = "";
}

$extfile = $folappstep."ws8_extensions.php";
$funfile = $folappstep."ws8_functions.php";

include $extfile;
include $funfile;
Thanks

Ben
Lts Media Ltd.
>snipped<

petr.pavel Mar 13th, 2008 6:16 pm
Re: open_basedir restriction in effect error in PHP
 
I do realize this was a fake post and an advertisement (judging from the snipped signature) but I'd like to add my five cents anyway, because the method described above is pretty crude.
An easy and elegant method is:
include dirname(__FILE__)."/ws8_extensions.php";
include dirname(__FILE__)."/ws8_functions.php";
BTW: Thanks for removing the ad. When we're at it, how about to close the thread as well so that it doesn't appear in unanswered threads search results? Thanks.


All times are GMT -4. The time now is 1:57 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC