For isntance...
Here is my directory:
[root folder]
+ data.php
+ user.php
+[FolderX]
++ index.php
++[FolderY]
+++test.php
How would I INCLUDE the data.php which is TWO LEVELS HIGHER?
I tried doing something like:
include("../../data.php");
But it wouldn't reach it...
Can someone help? Thanks...
Query: Can you 'include' a file that is up a level?
Moderator: General Moderators
-
randomblink
- Forum Commoner
- Posts: 51
- Joined: Wed Jan 28, 2004 11:27 am
- Location: Tulsa, Oklahoma, just this side of hell...
- Contact:
-
randomblink
- Forum Commoner
- Posts: 51
- Joined: Wed Jan 28, 2004 11:27 am
- Location: Tulsa, Oklahoma, just this side of hell...
- Contact:
Well as you're on a webhost, try this. In a file called .htaccess put:
php_value include_path /the/full/path/to/the/root/folder
Put the .htaccess directory in the root folder. This should allow you to require/include data.php in any file, from anywhere. The include_path sets the path to be searched when you use include or require.
php_value include_path /the/full/path/to/the/root/folder
Put the .htaccess directory in the root folder. This should allow you to require/include data.php in any file, from anywhere. The include_path sets the path to be searched when you use include or require.
-
randomblink
- Forum Commoner
- Posts: 51
- Joined: Wed Jan 28, 2004 11:27 am
- Location: Tulsa, Oklahoma, just this side of hell...
- Contact:
Bear with me...
When you say put the /full/path/to/the/root/folder in this .htaccess file, do you mean like this?
/root folder/
Or do you mean the path to the root folder FROM where the include file is?
/../../root folder/
or do you mean FROM the root folder TO the file that is INCLUDING...
/root folder/FolderX/test.php/
I am sorry to be so basic here, I just am confused...
When you say put the /full/path/to/the/root/folder in this .htaccess file, do you mean like this?
/root folder/
Or do you mean the path to the root folder FROM where the include file is?
/../../root folder/
or do you mean FROM the root folder TO the file that is INCLUDING...
/root folder/FolderX/test.php/
I am sorry to be so basic here, I just am confused...
When you tried to
did it output an error or anything? If it can't reach it, usually the error that is output is something like it cannot find the file or permission denied. Try echoing something from the data.php file so you can see when it is included.
Code: Select all
include('../../data.php');Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
randomblink
- Forum Commoner
- Posts: 51
- Joined: Wed Jan 28, 2004 11:27 am
- Location: Tulsa, Oklahoma, just this side of hell...
- Contact:
Ok. I entered the:
php_value include_path /the/full/path/to/the/root/folder
I cut and pasted the above line and copied over the:
/the/full/path/to/the/root/folder
with the output from a:
echo $_SERVER['DOCUMENT_ROOT'];
command... The command was run from a php file IN the root folder... (if that matters) But I ran it, cut and pasted it over the:
/the/full/path/to/the/root/folder
line... SO hopefully this works...!
Thanks for all your help...
php_value include_path /the/full/path/to/the/root/folder
I cut and pasted the above line and copied over the:
/the/full/path/to/the/root/folder
with the output from a:
echo $_SERVER['DOCUMENT_ROOT'];
command... The command was run from a php file IN the root folder... (if that matters) But I ran it, cut and pasted it over the:
/the/full/path/to/the/root/folder
line... SO hopefully this works...!
Thanks for all your help...