View Full Version : puzzling Php includes


juliagizzle
01-05-2007, 02:44 AM
Okay I am skinning my site with php includes and whatnot.
My directories are like this
/content
side.php
/skins
/1
header.php

I am trying to include side.php in header.php
<?php include("http://juliagizzle.net/content/side.php"); ?> works but I don't want to do that for my includes I want to use
<?php include("/content/side.php"); ?>
In the event I move ar change domains
however when I do that I get weird errors
like "no such directory or file"

what can I do?

thezeppzone
01-05-2007, 02:54 AM
So is header.php in the main directory or in another folder? So long as header.php is in the same directory as the content folder for side.php, there should be no reason why you shouldn't be able to use:

<?php include "content/side.php"; ?>

So try removing the parenthesis and the slash before content, and make sure the organization of the directories is correct to enable it to do such thing. If it doesn't work, mind posting the exact error and possibly a better way of showing your directory?

juliagizzle
01-05-2007, 03:12 AM
So is header.php in the main directory or in another folder? So long as header.php is in the same directory as the content folder for side.php, there should be no reason why you shouldn't be able to use:

<?php include "content/side.php"; ?>

So try removing the parenthesis and the slash before content, and make sure the organization of the directories is correct to enable it to do such thing. If it doesn't work, mind posting the exact error and possibly a better way of showing your directory?

oh the post didn't format the way my foders were set up.
/content
side.php
/skins
/1
header.php

header.php is is /skins/1
and side.php is in /content

thezeppzone
01-05-2007, 04:25 AM
Ok, try this:


include("../../content/side.php");


../ before content puts it back into the /1 directory, then ../ puts it back into the main directory, then calling the content directory and thus side.php. That one should work now that I see how the directories are setup.

juliagizzle
01-05-2007, 05:04 AM
okay I think I understand but just to clarify side.php
is in juliagizzle.net/content

thezeppzone
01-05-2007, 05:16 AM
Right. Try using the code I posted for the include:


<?php include("../../content/side.php"); ?>


and see how it works out

juliagizzle
01-05-2007, 07:45 PM
tried that this is what i get
Warning: main(../../content/side.php): failed to open stream: No such file or directory in /home/juliagiz/public_html/skins/1/header.php on line 13

Warning: main(../../content/side.php): failed to open stream: No such file or directory in /home/juliagiz/public_html/skins/1/header.php on line 13

Warning: main(): Failed opening '../../content/side.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/juliagiz/public_html/skins/1/header.php on line 13

juliagizzle
01-05-2007, 10:58 PM
This is really bugging me why is it that only the full url is working when i try to include another file in my header file which is located in another directory.
I tried using ../ to go up a directory but it is not working.