Jump to content

Archived

This topic is now archived and is closed to further replies.

Ninjakreborn

includes

Recommended Posts

I never had this problem
With includes.  I have my config.php and a few include's on it
The thing I don't get, when it's connected to the root directory pages it works, but now I am starting to get inclusion errors when adding it to processor's in the processor folder
I have my general include like this for the root folder's
[code]<?php
require_once './master/config/config.php';
?>[/code]
Now on my config page I have one's like
[code]// Handling php security issues
include './master/config/functions/security.inc.php'; // include file with security functions
error(5); // function to set error level, defaulted to all and strict.
inisettings("safe");
// include master function controller
include './master/config/functions/master.inc.php';
[/code]
The current problem though, this all work's properly with the other.  It come's down to the fact that there are a few problem's with something like a page within the master folder like
/master/includes/meta.inc.php
in this one, Ihave the include's but it's not working
in that folder, it give's me inclusion errors
is there a way I can setup those include's to make them work I just want to be able to use 1 require statement for all pages at the top, and it automatically include all the other pages without me having to modify all my include's for each page specifically, that wouldn't be possible anyway?

Share this post


Link to post
Share on other sites
when it comes to using 'common' files, i always tend to find $_SERVER['DOCUMENT_ROOT'] works quite well, as it then doesnt matter whether the common file is included from a file in the root, a sub dir, a sub sub dir, etc.

common.php:
[code]
<?php
$docroot = $_SERVER['DOCUMENT_ROOT'];

include($docroot . '/master/config/config.php');
include($docroot . '/master/somethingelse.php');
include($docroot . '/helloworld.php');
?>
[/code]

Share this post


Link to post
Share on other sites
That solved a shitload of problems.
Now what about using this for css and image names.
like
I tried
<link rel="stylesheet" type="text/css" href="<?php echo $docroot; ?>/css/global.css" />
I tried that and it didn't work, it wasn't reading the style's why.
That's not what I was originally using it for, but it was idea, unless you don't think it's worth the time?
I was going to try the same thing for javascript, and css.
IS that going to work, or are there going to be different affect's with those.

Share this post


Link to post
Share on other sites
this one's even easier. in HTML, EVERYTHING is relative to the docroot - so just use a trailing slash to reference the root of your website. works for anything HTML - css, javascript, etc.

[code]
<link rel="stylesheet" type="text/css" href="/css/global.css" />
[/code]

hope that helps
cheers
Mark

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.