Including A File Within A Directory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Majoraslayer
Forum Commoner
Posts: 64
Joined: Thu Jun 30, 2005 11:50 am
Location: In Your Mind...
Contact:

Including A File Within A Directory

Post by Majoraslayer »

Alright, now I'm trying to use include on some files within a directory. For some reason, it isn't working. If you can tell me something, please let me know. To see what I'm talking about, go to http://zorasdomain.com/phprogram/index.php

Code: Select all

<?php

include (&quote;/html/editorjava.html&quote;);

include (&quote;/html/index.html&quote;);

include (&quote;/html/editpopper.html&quote;);

?>
smo
Forum Newbie
Posts: 20
Joined: Tue May 31, 2005 11:02 pm

Post by smo »

If you are trying to include a file which is one step up in the path and inside html directory then use like this
include "../html/index.html";

If it is at one step up then
include "../index.html";

But from the root if you are trying to go one step up then permission problem will be there.

HTH
Majoraslayer
Forum Commoner
Posts: 64
Joined: Thu Jun 30, 2005 11:50 am
Location: In Your Mind...
Contact:

Post by Majoraslayer »

I tried adding the .. to the code, and no change. Also I CHMOD-ed the html directory to 777 (full permission), so I don't know what I'm missing. The book I'm reading on it said something about the include path, but within the syntax it assumes you're setting it on a local machine, with D:\somepath
smo
Forum Newbie
Posts: 20
Joined: Tue May 31, 2005 11:02 pm

Post by smo »

If you are in a server inv then you don't need to give path like D:/html ... that will not work.

From the present position ( path ) you have to calculate the file ( relative to the script location ) and include
Majoraslayer
Forum Commoner
Posts: 64
Joined: Thu Jun 30, 2005 11:50 am
Location: In Your Mind...
Contact:

Post by Majoraslayer »

I saw what the problem was; I just had to CHMOD the individual files instead of the directories they were contained in. Its working fine now, so thanks for the help anyway!
Post Reply