open_basedir restriction in effect error in PHP

Reply

Join Date: Feb 2008
Posts: 2
Reputation: BenR41 is an unknown quantity at this point 
Solved Threads: 0
BenR41 BenR41 is offline Offline
Newbie Poster

open_basedir restriction in effect error in PHP

 
0
  #1
Feb 25th, 2008
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.
  1. $folcnt = substr_count($_SERVER["PHP_SELF"], "/");
  2. $folappstep = "";
  3. if($folcnt > 1) {
  4. for($i=2;$i<=$folcnt;$i++) {
  5. $folappstep .= "../";
  6. }
  7. } else {
  8. $folappstep = "";
  9. }
  10.  
  11. $extfile = $folappstep."ws8_extensions.php";
  12. $funfile = $folappstep."ws8_functions.php";
  13.  
  14. include $extfile;
  15. include $funfile;
Thanks

Ben
Lts Media Ltd.
>snipped<
Last edited by MattEvans; Feb 25th, 2008 at 3:05 pm. Reason: Use [code] tags, don't use a fake signature.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 100
Reputation: petr.pavel is an unknown quantity at this point 
Solved Threads: 14
petr.pavel's Avatar
petr.pavel petr.pavel is offline Offline
Junior Poster

Re: open_basedir restriction in effect error in PHP

 
0
  #2
Mar 13th, 2008
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:
  1. include dirname(__FILE__)."/ws8_extensions.php";
  2. 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.
Petr 'PePa' Pavel

The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC