Jump to content

PHP Includes 1 directory deep


moleyb

Recommended Posts

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

$_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/

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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' );

Link to comment
Share on other sites

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

Link to comment
Share on other sites

/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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.