Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

include relative path problem

Status
Not open for further replies.

wendyp

IS-IT--Management
Mar 4, 2003
51
US
My grand idea is to set up a "test" area. So from my public_html directory, I will have "test" and "prod". I will have one file paths.php which sets the $URLpath and the $WEBpath to the appropriate area - then I only have to change one thing.

Problem:
PATHS.PHP has a path of:
/home/username/public_html/test/paths.php

The script I'm running has the following path:
/home/username/public_html/test/Scripts/signup/login.inc.php

And so I've tried putting an include statement in the login file:

include("../../paths.php") was my first choice - that seemed right to me.

That didn't work - failed to open stream: No such file or directory

so then I tried:
"../paths.php"
"../../../paths.php"
"../../../../paths.php"

None work. Why isn't this working? I can't go from the top down, because I want this to be able to work for the test as well as the production directory.

/Wendy
 
try $_SERVER['DOCUMENT_ROOT']

Bastien

Cat, the other other white meat
 
If you start the relative path like:
/test/ -> will go from the document_root, I think.
test/ -> subfolder "test"
../ -> will look for the parent folder of current
/ -> document-root

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top