Click to See Complete Forum and Search --> : Proper <include> path when linking


Aronya1
02-14-2004, 03:48 AM
OK, here's my next question. I'm trying to use an <include> statement in a web page. The page I'm coding is one level below the file being called in the <include>:

/home/sitename/public_html/folder/page.php (page being coded)
/home/sitename/public_html/footer.php (the file being called in the <include>)

I can't seem to get the path statement right. I've tried the following:
<? include('footer.php'); ?>
<? include('/footer.php'); ?>
<? include('./footer.php'); ?>
<? include('...footer.php'); ?>
<? include('.../footer.php'); ?>

I'd like to use this shorthand version instead of the full http:\\ path, but I'm missing something.

When I open the page, I get this error: "Warning: main(./footer.php): failed to open stream: No such file or directory in /home/sitename/public_html/folder/page.php"

YoN
02-14-2004, 01:58 PM
Try<?php include('../footer.php'); ?> ;)
BTW, it's better to use <?php instead of <?

Aronya1
02-14-2004, 02:05 PM
Thanks for the FYI, but it doesn't change anything.

YoN
02-14-2004, 02:14 PM
Did you use my code?... To include a file that is on a higher level, you need to add '../' [Just two periods and a slash] as many times as levels you want to go up.
Please double check. If not, post your code.

Aronya1
02-14-2004, 03:25 PM
Thanks. That did the trick. Looks like I was dancing all around the answer, but couldn't trip over it. Thought you were pointing out the <?php part.

YoN
02-14-2004, 05:10 PM
Great! :)