Jump to content


Photo

php include not working


  • Please log in to reply
3 replies to this topic

#1 jacobjmorris

jacobjmorris
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 09 June 2006 - 02:45 AM

My php include is not working:

<?php include('/components/include/banner.php'); ?>

This is the error message I get:

Warning: main(): open_basedir restriction in effect. File(/components/includes/banner.php) is not within the allowed path(s): (/home/gayeecom/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/gayeecom/public_html/about/index.php on line 26


However, if I were to move banner.php within the same folder as the file I'm trying to include it, then it works fine. So, I'm guessing this has something to do with how I'm constructing the file path?

Jacob



#2 DXPhoenix323

DXPhoenix323
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 09 June 2006 - 02:51 AM

[!--quoteo(post=381707:date=Jun 8 2006, 10:45 PM:name=jacobjmorris)--][div class=\'quotetop\']QUOTE(jacobjmorris @ Jun 8 2006, 10:45 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
My php include is not working:

<?php include('/components/include/banner.php'); ?>

This is the error message I get:

Warning: main(): open_basedir restriction in effect. File(/components/includes/banner.php) is not within the allowed path(s): (/home/gayeecom/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/gayeecom/public_html/about/index.php on line 26
However, if I were to move banner.php within the same folder as the file I'm trying to include it, then it works fine. So, I'm guessing this has something to do with how I'm constructing the file path?

Jacob
[/quote]

I used to get something similar to this back when PHP upgraded to PHP4... Try adding the at sign @ between <?php and include to create:

<?php @ include('/components/include/banner.php'); ?>

That should do it... PHP can be analretentive with technicalities... Let me know if that works...

-Ross :D

#3 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 09 June 2006 - 02:59 AM

[!--quoteo(post=381710:date=Jun 8 2006, 09:51 PM:name=DXPhoenix323)--][div class=\'quotetop\']QUOTE(DXPhoenix323 @ Jun 8 2006, 09:51 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I used to get something similar to this back when PHP upgraded to PHP4... Try adding the at sign @ between <?php and include to create:

<?php @ include('/components/include/banner.php'); ?>

That should do it... PHP can be analretentive with technicalities... Let me know if that works...

-Ross :D
[/quote]

adding the @ just supresses the warning rather than getting rid of it. It seems like the problem is you're not allowed to access the basdir which is /. If your script file is located in /home/gayeecom/scripts/script.php and you want to include a file in /home/gayeecom/scripts/components/include/banner.php you have to either use the full path or components/include/banner.php (notice the lack of / at the beginning). Basically what I'm saying is never start the filepath with / unless you're going to use the full filepath.
[table]



Don't worry, the printer fairies will sort it out.

#4 jacobjmorris

jacobjmorris
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 09 June 2006 - 03:06 AM

Hey Rob

Thanks for the tip! I did get it to work using:

<?php include('http://www.website.c...udes/banner.php'); ?>

However, I should be able to make this path relative, so when I try:

/components/includes/banner.php

or

../components/includes.banner.php

it doesn't work, any ideas?

just figured out how to do it, have to start at the base directory on the server, i got it working

thanks guys for your input! it was really helpful




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users