Jump to content
Larry Ullman's Book Forums

Recommended Posts

I have following file structure :

 

home ----

.----- includes folder

. ------- header file

------ footer file

----- www folder

---- index.php file

---- submit.php file

---- articles.php

 

footer file includes file like this : include("../www/articles.php");

 

index and submit file includes files like these: include("../includes/footer.html");

 

articles.php does not include header and footer, as it itself is included inside footer.html. (articles list are shown on each page.)

 

Now, index file shows correct formatting and output. But, submit page shows error including articles.php.

So, how do I make the relative path over here? What am I missing understanding things about relative paths?

Link to comment
Share on other sites

You don't need to use $_SERVER['DOCUMENT_ROOT'] to identify the document root because PHP already assumes that the directory the script being executed is in is the current directory.

 

So again I will ask: Why are you placing ../ at the beginning of your paths?

Link to comment
Share on other sites

../ to get out of the current directory and reach to the home directory. home folder contains includes and www folder. And then, includes folder contains header and footer file. Other 3 files are in www folder. That's my file structure, which is not showing in the figure.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...