sonal Posted June 19, 2012 Share Posted June 19, 2012 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 More sharing options...
HartleySan Posted June 20, 2012 Share Posted June 20, 2012 Why are you placing ../ at the beginning of your paths? Link to comment Share on other sites More sharing options...
sonal Posted June 20, 2012 Author Share Posted June 20, 2012 I read that, $_SERVER['DOCUMNET_ROOT'] identifies the document location. Link to comment Share on other sites More sharing options...
HartleySan Posted June 20, 2012 Share Posted June 20, 2012 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 More sharing options...
sonal Posted June 20, 2012 Author Share Posted June 20, 2012 ../ 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 More sharing options...
HartleySan Posted June 21, 2012 Share Posted June 21, 2012 Could you please provide an accurate and easy-to-understand diagram of your file structure then? Link to comment Share on other sites More sharing options...
Recommended Posts