phpQuestioner Posted August 10, 2007 Share Posted August 10, 2007 I want to be able to use a include from one sub-directory; to add to a page in another sub-directory, but I am having problem getting it to display. I tried to do like the manual said, but for some reason; it does not seem to be working (it does not display anything at all). Any one got any idea why not? Code Below......... <?php // this would be number.php page from sub-directory1 $mynumber="000-000-0000"; ?> <?php // this would be the page in sub-directory2 include 'http://www.domain.com/sub-directory1/number.php'; echo "$mynumber"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/ Share on other sites More sharing options...
keeB Posted August 10, 2007 Share Posted August 10, 2007 Can't include over http:// Include over the file system. Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320063 Share on other sites More sharing options...
phpQuestioner Posted August 10, 2007 Author Share Posted August 10, 2007 So your page has to be in same sub-directory as your included page for the include to work - right? Is that what you are saying? Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320068 Share on other sites More sharing options...
dbo Posted August 10, 2007 Share Posted August 10, 2007 Nope. Say you have something like this: Folder1 number.php Folder2 index.php To include number.php in index.php you'd put something like include_once "../Folder1/number.php"; The 2 dots say go up a level and then look for Folder1. Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320073 Share on other sites More sharing options...
phpQuestioner Posted August 10, 2007 Author Share Posted August 10, 2007 Well my folder layout is something like this: -Domain - Sub 1 - Folder 1 (page to include here) - Folder 2 (page I want include in here) Folder 1 & Folder 2 are in the same level. So how would the include work this way or will it not work at all this way? Would you just do this: <?php include_once("Folder1/number.php"); echo "mynumber"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320078 Share on other sites More sharing options...
optikalefx Posted August 10, 2007 Share Posted August 10, 2007 that looks like they are in the same sub directory. it would just be include 'number.php'; Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320079 Share on other sites More sharing options...
dbo Posted August 10, 2007 Share Posted August 10, 2007 Pretty sure it's exactly what I said. Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320081 Share on other sites More sharing options...
phpQuestioner Posted August 10, 2007 Author Share Posted August 10, 2007 there is two sub-directories in one sub-directory (the hierarchy is just as I have it in the example i have [iurl=http://www.phpfreaks.com/forums/index.php/topic,154076.msg666865.html#msg666865]here[/iurl]). one of these two sub-directories contain the php file to include and the other sub-directory contains the php file I want the include to be put in. ok, tried it like you said; but it's still not there. <?php include_once("..Folder1/number.php"); echo "$mynumber"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320082 Share on other sites More sharing options...
dbo Posted August 10, 2007 Share Posted August 10, 2007 You didn't try like i said. I said ../Folder1/file.php you put ..Folder1/file.php Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320086 Share on other sites More sharing options...
phpQuestioner Posted August 10, 2007 Author Share Posted August 10, 2007 ok - i see - thank you dbo - it works now Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320087 Share on other sites More sharing options...
dbo Posted August 10, 2007 Share Posted August 10, 2007 You're welcome. Quote Link to comment https://forums.phpfreaks.com/topic/64205-solved-how-to-use-include-for-another-sub-directory/#findComment-320088 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.