RandomClown Posted December 1, 2009 Report Share Posted December 1, 2009 (edited) 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);?> Edited December 1, 2009 by RandomClown Link to comment Share on other sites More sharing options...
fulbish Posted December 1, 2009 Report 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 Report 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 Report Share Posted December 3, 2009 (edited) 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. Edited December 3, 2009 by RandomClown Link to comment Share on other sites More sharing options...
thescientist Posted December 3, 2009 Report Share Posted December 3, 2009 (edited) nm, i read that wrong.so your included file is in the root directory? Edited December 3, 2009 by thescientist Link to comment Share on other sites More sharing options...
RandomClown Posted December 3, 2009 Author Report Share Posted December 3, 2009 (edited) 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] Edited December 3, 2009 by RandomClown Link to comment Share on other sites More sharing options...
Synook Posted December 3, 2009 Report 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 Report 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 Report 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 Report Share Posted December 3, 2009 (edited) 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"); Edited December 3, 2009 by Ingolme Link to comment Share on other sites More sharing options...
RandomClown Posted December 3, 2009 Author Report 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 Report 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 Report Share Posted December 3, 2009 phew Link to comment Share on other sites More sharing options...
Synook Posted December 3, 2009 Report Share Posted December 3, 2009 (edited) Note: you can use the $_SERVER["DOCUMENT_ROOT"] superglobal index to quickly access your document root (which will also change when you move servers). Edited December 3, 2009 by Synook Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now