Forum Moderators: coopster

Message Too Old, No Replies

Absolute Path

Does not work on folders above root

         

russgri

3:22 am on Jul 6, 2004 (gmt 0)

10+ Year Member



This file is /public_html/about/index.php
...using else/if to carry all files in the about folder; main, bio, contacts, mission etc;
I am trying to adapt this to my template.

<?php
$inc = $_SERVER["DOCUMENT_ROOT"]."/inc";
include $inc."/config.php";
include $about."/setup.php";
include $inc."/header.php";
include $inc."/topnav.php";
include $inc."/left.php";
include $inc."/right.php";
if(!$_SERVER['QUERY_STRING']) {?>
<div id="content">
<H2>Our Mission</H2>
<p>We will continue our efforts to widen our scope to include....
</div>
<? } elseif ($_SERVER['QUERY_STRING'] == "bio") {?>
Ipsum Lorum.....
<? }
include $inc."/footer.php";?>

Here is my config.php
[code]
<?php
$server = $_SERVER["DOCUMENT_ROOT"]."/";
$inc = $_SERVER["DOCUMENT_ROOT"]."/inc";
$about = $_SERVER["DOCUMENT_ROOT"]."/about";
?>
[code]
This above file is in the about folder...
I have coded for absolute path to includes but it is not working.
Also....Please review my code with respect to correct footer includes...
Thanks

coopster

8:30 pm on Jul 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Is the config.php file in the about folder? If so, you're never getting it included because it's not in the path during assignment at the top of your code...
include $inc."/config.php";
...or am I missing something?

russgri

3:34 am on Jul 7, 2004 (gmt 0)

10+ Year Member



This file is /public_html/about/index.php

All that is wrong...correct me...is that the absolute coding is wrong.

This works:


<?
include( '../inc/config.php' );
include( 'setup.php' );
include( '../inc/header.php' );
include( '../inc/topnav.php' );
include( '../inc/left.php' );
include( '../inc/right.php' );
include( '../inc/footer.php' );
if(!$_SERVER['QUERY_STRING'])?>
<div id="content">
<H2>Our Mission</H2>
<p>We will continue our efforts....</p>

</div>
<? } elseif ($_SERVER['QUERY_STRING'] == "contact") {?>
<div id="content">
<H2>Contact Info</H2>
<p>Our address is....</p>

<? )
include( '../inc/footer.php' );
?>


calls with:
About: index.php?about

This worls but ...How could I use absolute includes?

ergophobe

3:40 pm on Jul 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So your directory structure is like this

public_html
=>inc
=>=>config.php
=>about
=>=>index.php

So yes, it should be

include($_SERVER['DOCUMENT_ROOT'] . '/inc/config.php');
include($_SERVER['DOCUMENT_ROOT'] . '/about/index.php');

If it's not working, echo out the paths and see if you are missing something:

$path = "path/to/page/";
echo $path;
include($path);