[SOLVED] include() trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

[SOLVED] include() trouble

Post 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?
Last edited by HiddenS3crets on Thu Dec 15, 2005 5:47 pm, edited 4 times in total.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Code: Select all

include(dirname($_SERVER['DOCUMENT_ROOT']).'/pathtomyfiles/myfile.php');
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

Post by HiddenS3crets »

not quite what i'm looking for :?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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
HiddenS3crets
Forum Contributor
Posts: 119
Joined: Fri Apr 22, 2005 12:23 pm
Location: USA

Post by HiddenS3crets »

nevermind, I ended up fixing it :wink:
Post Reply