liamloveslearning Posted July 3, 2008 Share Posted July 3, 2008 I have an include on my website, and its 1 level up in the directory above my page (if that makes sense) include'member_header.php'; is my include code; is it something like? include'//member_header.php'; Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/ Share on other sites More sharing options...
rmmo Posted July 3, 2008 Share Posted July 3, 2008 hi have you tried the full file path? like a hyperlink would that work? just a thought. hope it helps RMMO Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581066 Share on other sites More sharing options...
themistral Posted July 3, 2008 Share Posted July 3, 2008 Try include('../member_header.php'); Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581069 Share on other sites More sharing options...
liamloveslearning Posted July 3, 2008 Author Share Posted July 3, 2008 ive not tried the full root yet no, i want it relative to the site and to include it on all pages; and ive tried include('../member_header.php'); to no avail. can i just ask the .. tells the browser to look a directory abouve the current page? sorry if my wording seems all mumble jumble and thanks! Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581073 Share on other sites More sharing options...
themistral Posted July 3, 2008 Share Posted July 3, 2008 can i just ask the .. tells the browser to look a directory abouve the current page? That's what my code should do... Is the file you are including member_header.php being used as an included file as well? That sometimes messes the paths up. Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581077 Share on other sites More sharing options...
PFMaBiSmAd Posted July 3, 2008 Share Posted July 3, 2008 I recommend forming an absolute file system path using $_SERVER['DOCUMENT_ROOT'] so that include() statements can find the path/file no matter what the path is or where the file is that is including another file. Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581087 Share on other sites More sharing options...
liamloveslearning Posted July 3, 2008 Author Share Posted July 3, 2008 sorry it needs to move up 2 directories is it include('../../member_header.php'); whats the code for moving it down a directory? Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581088 Share on other sites More sharing options...
liamloveslearning Posted July 3, 2008 Author Share Posted July 3, 2008 nevermind i just needed to move it up more directories than i thought thanks Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581094 Share on other sites More sharing options...
wildteen88 Posted July 3, 2008 Share Posted July 3, 2008 Yes ../ is to go one level higher. To go down a level you specify the directory in the current level. However I highly suggest PFMaBiSmAd's comment. When using include's always do include $_SERVER['DOCUMENT_ROOT'] . 'path/to/file.php' This eliminates the need to use ../ in your paths. PHP will locate files from your websites root folder (where you upload your sites files to). Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581103 Share on other sites More sharing options...
PFMaBiSmAd Posted July 3, 2008 Share Posted July 3, 2008 And even though you got it working where the main file is located now, if you should move the main file up or down a level or reuse that code in a different folder structure, it will stop and you will need to go back and figure out a new relative path. Forming an absolute file system path using DOCUMENT_ROOT will allow the include() statement to work no matter what folder the file is in. Quote Link to comment https://forums.phpfreaks.com/topic/113114-solved-include-directory/#findComment-581111 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.