Jump to content


Photo

includes


  • Please log in to reply
5 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 23 October 2006 - 07:30 PM

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
<?php
require_once './master/config/config.php';
?>
Now on my config page I have one's like
// 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';
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?

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 October 2006 - 07:42 PM

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:
<?php
$docroot = $_SERVER['DOCUMENT_ROOT'];

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

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 23 October 2006 - 07:45 PM

Thank's that's just what I needed.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#4 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 23 October 2006 - 07:58 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#5 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 October 2006 - 08:52 PM

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.

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

hope that helps
cheers
Mark
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#6 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 23 October 2006 - 09:07 PM

hmm ok.
This should help me make things more re-usable, and less work.

Thanks again.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users