Posted by Ron on 09/25/07 07:07
Hi all,
Trying to work out a few problems in using php on my site. Partially
this is a html question. I was reading a lot of the posts and it seems
that some of the includes people are using are very complicated because
of sessions or id's and variables I don't really know. So...
Right now i use php for includes and getting some lists I make using
mySQL and phpmyadmin and can get those out without error. For the most
part a lot of my files were in the main directory with my index.php
like header.php and footer.php but I just realized when I use these
header and footer files from a different directory the paths are wrong.
I was doing the includes like:
<?php include("header.php"); ?> Links are good
<?php include("../header.php"); ?> Links are bad
<?php include("../../header.php"); ?> Links are bad
The linked file in the header file would be at the same level as index
but now as I have added pages I have made folders to keep things
organized. My goal is to call my header or footer file from any level
folder from an includes folder.
<?php include("includes/header.php"); ?> being called from collies in
mysite/pets/dogs or whatever.
My solution is to make the link the full path with http://mysite.com
and so on so regardless of where the header is called from the link is
good. I always thought that relative paths are used within a site and
full paths to link outside. My solution will work but I think there is
a better way.
So should I have my include files at the same level as my index file?
or in a folder?
Use full path?
And should these include files use a .inc extension instead of php?
Sorry this is a bit long for such a simple topic but I have to get
organized. :)
thx..ron
Navigation:
[Reply to this message]
|