moleyb Posted September 22, 2010 Share Posted September 22, 2010 Hi Guys, im really hoping one of you php guru's can shed some light on this as its being bugging me for months... Im trying you access a php include, in a page 1 directory deep into a site (say one down from the index.php) - with no luck. My includes are in a folder that is on the same level as the index.php file for the website. Iv tried using this way: <? include("../includes/footer.php"); ?> And this way: <?php include $_SERVER['DOCUMENT_ROOT'] . "includes/footer.php"; ?> It works locally (using MAMP), but not live on the net. Im getting this error: Warning: main() [function.main]: open_basedir restriction in effect. File(/ext/default/includes/footer.php) is not within the allowed path(s): (.:/tmp) in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Warning: main(/ext/default/includes/footer.php) [function.main]: failed to open stream: Operation not permitted in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Warning: main() [function.include]: Failed opening '/ext/default/includes/footer.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Really appreciate anyone who has a few minutes to look at this. Cheers Guys Mike Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/ Share on other sites More sharing options...
Chris92 Posted September 22, 2010 Share Posted September 22, 2010 Try: <?php dirname(__FILE__); ?> Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114076 Share on other sites More sharing options...
Chris92 Posted September 22, 2010 Share Posted September 22, 2010 Actually reading through the errors you are getting it seems more like your file permissions aren't set right on your directories. Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114078 Share on other sites More sharing options...
moleyb Posted September 22, 2010 Author Share Posted September 22, 2010 Cheers for looking at this Chris, Iv set the includes folder to 777 for now, and it still not happy : ( Actually my question is slight off for where im testing it right now. Im actually trying to access an includes folder that is 1 folder back (and not in the root folder of the site). Can I ask what do you use for that? Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114081 Share on other sites More sharing options...
PFMaBiSmAd Posted September 22, 2010 Share Posted September 22, 2010 $_SERVER['DOCUMENT_ROOT'] is not setup properly on your server. You would need to speak with your web host to get it corrected. It is set to /ext/default/ For your account, it should be set to your document root folder, which looks like it should be /ext/f/fo/fourthelement.com/html/ Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114082 Share on other sites More sharing options...
Chris92 Posted September 22, 2010 Share Posted September 22, 2010 Try this: include( dirname(__FILE__) . '/../includes/footer.php' ); Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114083 Share on other sites More sharing options...
moleyb Posted September 22, 2010 Author Share Posted September 22, 2010 Thanks PFMaBiSmAd, ill look into that for when I put it on its own hosting. Cheers Chris, didn't seem to like it again got this error: Warning: main() [function.main]: open_basedir restriction in effect. File(/ext/f/fo/fourthelement.com/html/sita/resources/../includes/footer.php) is not within the allowed path(s): (.:/tmp/) in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Warning: main(/ext/f/fo/fourthelement.com/html/sita/resources/../includes/footer.php) [function.main]: failed to open stream: Operation not permitted in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Warning: main() [function.include]: Failed opening '/ext/f/fo/fourthelement.com/html/sita/resources/../includes/footer.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Any suggestions, thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114090 Share on other sites More sharing options...
moleyb Posted September 23, 2010 Author Share Posted September 23, 2010 Hi Guys, didn't manage to resolve this yet. Any help would be very much appreciated. Mike Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114401 Share on other sites More sharing options...
Chris92 Posted September 23, 2010 Share Posted September 23, 2010 What you could do is first define the $_SERVER['DOCUMENT_ROOT']; $_SERVER['DOCUMENT_ROOT'] = '/ext/f/fo/fourthelement.com/html/'; include( $_SERVER['DOCUMENT_ROOT'] . 'includes/footer.php' ); or just use the complete path in your include: include( '/ext/f/fo/fourthelement.com/html/includes/footer.php' ); Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114409 Share on other sites More sharing options...
moleyb Posted September 23, 2010 Author Share Posted September 23, 2010 Hi Chris, Thanks again for taking a look. I just can't see how its failing! Using the complete path I get this error: Warning: main() [function.main]: open_basedir restriction in effect. File(/ext/f/fo/fourthelement.com/html/includes/footer.php) is not within the allowed path(s): (.:/tmp/) in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Warning: main(/ext/f/fo/fourthelement.com/html/includes/footer.php) [function.main]: failed to open stream: Operation not permitted in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Warning: main() [function.include]: Failed opening '/ext/f/fo/fourthelement.com/html/includes/footer.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /ext/f/fo/fourthelement.com/html/sita/resources/members_area.php on line 53 Here's a URL to what im working on: http://www.fourthelement.com/sita/resources/members_area.php Many thanks Mike Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114413 Share on other sites More sharing options...
Chris92 Posted September 23, 2010 Share Posted September 23, 2010 /ext/f/fo/fourthelement.com/html/includes/footer.php I'm guessing should be /ext/f/fo/fourthelement.com/html/sita/includes/footer.php If it's not the case you might want to look at this: not within the allowed path(s) This is more to do with your host than any PHP. You'll have to contact your host and show them the error. Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114418 Share on other sites More sharing options...
moleyb Posted September 23, 2010 Author Share Posted September 23, 2010 Cheers Chris, yeah I did try that as well. Im guessing its down to my host and "not within the allowed path(s)". Thanks so much for taking the time to look at this. Really Appreciate it. Maybe one day ill resolve this issue! Cheers mate. Quote Link to comment https://forums.phpfreaks.com/topic/214104-php-includes-1-directory-deep/#findComment-1114420 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.