Page 1 of 1

[SOLVED] include() trouble

Posted: Thu Dec 15, 2005 5:32 pm
by HiddenS3crets
I include files in a file that is included on every page on my site.

Example:
top.php

Code: Select all

// Some html stuff is here
<?php
include('/con.php');
include('/function.php');
?>
// Other html stuff is here
Then in all my files I include top.php. The problem is that when I include top.php in a subdirectory of my site, con.php and functions.php won't be included too. How can I fix this?

Posted: Thu Dec 15, 2005 5:35 pm
by hawleyjr

Code: Select all

include(dirname($_SERVER['DOCUMENT_ROOT']).'/pathtomyfiles/myfile.php');

Posted: Thu Dec 15, 2005 5:39 pm
by HiddenS3crets
not quite what i'm looking for :?

Posted: Thu Dec 15, 2005 5:45 pm
by Burrito
if they are at the root include them like this:

Code: Select all

include("/somefile.php");
edit: you edited your two posts while I was posting this 8O

Posted: Thu Dec 15, 2005 5:47 pm
by HiddenS3crets
nevermind, I ended up fixing it :wink: