RandomClown Posted December 1, 2009 Share Posted December 1, 2009 ok, this might be a noob question.I was trying to use the include function but failed.I looked through lots of pages fitting my syntax to their design if possible, but still fail.How would I get this to work? <?php$page="/Projects/Posts/Test.php";include($page);?> Link to comment Share on other sites More sharing options...
fulbish Posted December 1, 2009 Share Posted December 1, 2009 is your include path correct? $page="/Projects/Posts/Test.php"; if the Projects folder is in the same folder as your php script thennotice the leading slash in your path //if the Projects folder is in the same folder as your php script//it should be like this$page="Projects/Posts/Test.php";//and NOT like this//this is WRONG$page="/Projects/Posts/Test.php"; Link to comment Share on other sites More sharing options...
jeffman Posted December 1, 2009 Share Posted December 1, 2009 let's check everything else while we're at it.What makes you sure it's failing? What behavior did you expect? What did you get instead? Were their error or warning messages? The your page generate anything at all? (Was it supposed to) Did you get a totally blank screen? What makes you certain the include statement is to blame? Link to comment Share on other sites More sharing options...
RandomClown Posted December 3, 2009 Author Share Posted December 3, 2009 Thanks for your reply. Wasn't sure where to start with this post.I am sure it fails since the rest of the php script worksThe path is correct, the beginning slash to start from the root.Here is the exact script, which is in some sub-folder: <div class="Border HovBooa PadAllExR"> <div> <img onclick="ToggleVis(this,'<?php echo $_GET["ID"];?>');" style="cursor:pointer" src="/src/Functions/JS/ToggleVis/-.png" alt="-" /> <span class="Sec2"><?php echo $_GET["Title"];?>:</span> </div> <div class="PadL" id="<?php echo $_GET["ID"];?>"> <?php echo "lolcats";include("/index-Bar.php");?> </div> </div>f If I open the page like so: PageMainSection.php?ID=ChangeLog&Title=Change Log Here is the output: <div class="Border HovBooa PadAllExR"> <div> <img onclick="ToggleVis(this,'ChangeLog');" style="cursor:pointer" src="/src/Functions/JS/ToggleVis/-.png" alt="-" /> <span class="Sec2">Change Log:</span> </div> <div class="PadL" id="ChangeLog"> lolcats </div> </div>f The output is everything except the content of the file [no, its not empty]Hope this helps. Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 nm, i read that wrong.so your included file is in the root directory? Link to comment Share on other sites More sharing options...
RandomClown Posted December 3, 2009 Author Share Posted December 3, 2009 nm, i read that wrong.so your included file is in the root directory?In this example, yep.I do hope to move it into sub-folders though.BTW I am using sourceforge.net:[Page]if you go to the include file, you will see its there:http://horc.sourceforge.net/index-Bar.php[see the page source] Link to comment Share on other sites More sharing options...
Synook Posted December 3, 2009 Share Posted December 3, 2009 Note - when you refer to the root directory on the server, that refers to the system root (not the document root). Link to comment Share on other sites More sharing options...
RandomClown Posted December 3, 2009 Author Share Posted December 3, 2009 ??Does that mean I need to do include("http://horc.sourceforge.net/index-Bar.php")?That didn't work either. Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 is Index-Bar.php only supposed to display two empty div's that you can click on? Link to comment Share on other sites More sharing options...
Ingolme Posted December 3, 2009 Share Posted December 3, 2009 Include the file relative to the current location, or if you know how the system is organized, then you can do it relative to the system root:include("../file.php");orinclude("/apache/sites/mydomain.com/www/file.php"); Link to comment Share on other sites More sharing options...
RandomClown Posted December 3, 2009 Author Share Posted December 3, 2009 is Index-Bar.php only supposed to display two empty div's that you can click on?lol that was only a test. I dont plan to use it on that PHP file. What I plan to use it on does not exist yet.Include the file relative to the current location, or if you know how the system is organized, then you can do it relative to the system root:include("../file.php");orinclude("/apache/sites/mydomain.com/www/file.php");ohh I think I get it now.**Testing**IT WORKS!!I did <?php echo "lolcats";include("/home/groups/h/ho/horc/htdocs/".$_GET["Content"]);?> Thanks a bunch everyone Link to comment Share on other sites More sharing options...
RandomClown Posted December 3, 2009 Author Share Posted December 3, 2009 Now that includes work for sure, time to redo my site!lol....work.. Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Share Posted December 3, 2009 phew Link to comment Share on other sites More sharing options...
Synook Posted December 3, 2009 Share Posted December 3, 2009 Note: you can use the $_SERVER["DOCUMENT_ROOT"] superglobal index to quickly access your document root (which will also change when you move servers). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.