Jump to content


Php include() Help


7 replies to this topic

#1 danieldaniel

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male
  • Location:Columbus, Ohio
  • Interests:Skateboarding, Macs, BMX, Cocoa, PHP, CSS etc.

Posted 12 July 2006 - 02:30 AM

Whenever I try to use includes I get this error.

Quote

Warning: main(): open_basedir restriction in effect. File(/test) is not within the allowed path(s): (/home3/whatever:/tmp) in /home3/whatever/public_html/daniel/index.php on line 2

Warning: main(/test): failed to open stream: Operation not permitted in /home3/whatever/public_html/daniel/index.php on line 2

Warning: main(): Failed opening '/test' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home3/whatever/public_html/daniel/index.php on line 2

Here is the code I am using.

<?
include("/test");
?>

What is wrong!?!?! I am linking to /test, not /usr/lib/php whatever. This is driving me CRAZY! lol. Thanks :P.

Edited by danieldaniel, 12 July 2006 - 02:32 AM.


#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 12 July 2006 - 02:37 AM

if i am correct you can't include a directory, only a file within a director, so:

include("test.php");
is allowed

include("test/test.php");
is allowed

include("test");
is not allowed

Hope that helps

#3 danieldaniel

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male
  • Location:Columbus, Ohio
  • Interests:Skateboarding, Macs, BMX, Cocoa, PHP, CSS etc.

Posted 12 July 2006 - 02:49 AM

Hmm, I changed it to use /test/index.php, but I got the same error. Is that what you meant?

#4 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 12 July 2006 - 04:28 AM

try...

include "test/index.php";

Without the preceeding /.

#5 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 12 July 2006 - 12:25 PM

include "test";
That is allowed, becaue you could have a file simply named "test"

The reason you get the open_basedir() error is because you're trying to include something from your root directory. PHP isn't HTML, when you have that preceding slash, it looks deeper in the server than the public_html directory.

#6 N4Z.

    Call me Yoda

  • Members
  • PipPipPipPip
  • 3,016 posts
  • Gender:Male
  • Location:127.0.0.1
  • Interests:Designing, Apple Fan Boy, Music Production and Weekends!

Posted 12 July 2006 - 04:23 PM

Well said.. Im still learning PHP. I find PHP Includes tricky to use too sometimes, but after a while it just clicks and you find yourself doing it as easy as you do HTML links <a href="pixel2life.com"> P2L</a> But yeah.. try www.phpfreaks.com - A lot of good stuff there my friend.

#7 danieldaniel

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male
  • Location:Columbus, Ohio
  • Interests:Skateboarding, Macs, BMX, Cocoa, PHP, CSS etc.

Posted 12 July 2006 - 06:12 PM

Ahhh, ok I got it using home3/whatever/public_html/test/index.php. Thanks!

#8 Aussiestinger

    Young Padawan

  • Members
  • Pip
  • 270 posts

Posted 12 July 2006 - 06:26 PM

You shouldn't need all that,

just test/index.php

or index.php if the file you are linking from is in /test/





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users