As you include things, the relative include paths are relative to the current document. I have tried re-writing the script with absolute paths, but that did not work. Can I set a script to execute setting the current path relative to it?
In other words
I have index.php, a folder "includes" and in there, "db.inc" and "readdb.inc". From index.php, I want to include "includes/readdb.inc", and I want to be able to access "db.inc" from "readdb.inc" using the relative path simply "db.inc".
Thanks for any help...
-OmniUni
Setting Your Include Path
Moderator: General Moderators
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
Re: Setting Your Include Path
No, I don't think so. The path is relative to the executing script, in this case index.php. In other words, once you include db.inc into index.php, it becomes a part of index.php, so a reference to "readdb.inc" will look in the same folder of index.php... and fails 
Re: Setting Your Include Path
Thank you.
Apparently it is something about the way the script I am using is written; I went through and set relative paths as from the executing script by hand, and it worked.
I had tried creating a variable to use as the path, and that failed miserably, for some reason.
Thanks again,
OmniUni
Apparently it is something about the way the script I am using is written; I went through and set relative paths as from the executing script by hand, and it worked.
I had tried creating a variable to use as the path, and that failed miserably, for some reason.
Thanks again,
OmniUni
-
andychamberlainuk
- Forum Newbie
- Posts: 6
- Joined: Mon Jul 28, 2008 7:15 pm
Re: Setting Your Include Path
if you want absolute links, you must include your entire server path (whether it be local or on a server)
Here's the code I use: -
By using this, you can be sure that you are including the correct documents EVERY time!
Here's the code I use: -
Code: Select all
include_once ($_SERVER['DOCUMENT_ROOT'] . "/classes/mysql.php");