Jump to content

Include Function Problem


foochuck

Recommended Posts

I've been using the include function on my website. However, I recently started making some sub-folders on my site and any pages in those folders aren't pointing to the correct include file.

 

/mysite.com/includes/functions.php

 

<?php include("includes/functions.php"); ?>

 

So that's the code I'm using on all of my pages through a template.

 

I've tried an absolute path the the include function but it doesn't work.

 

I've tried looking up several work arounds for this but haven't been able to get it to work on my site.

 

Could someone show me how to make the include be an absolute path to the file so it works throughout every directory of my website?

 

Thanks

 

FOO

Link to comment
https://forums.phpfreaks.com/topic/116395-include-function-problem/
Share on other sites

Samshel - do I define the CFG_ROOT constant in my website homepage? Or does it not matter where I define this?

 

Also is this correct for my directory structure? :

 

define("CFG_ROOT", "/www.mysite.com/");

 

FYI - when I connect to my server through FTP /www.mysite/ is the highest folder I can access.

 

//define root path in some config.
define("CFG_ROOT", "/var/www/html/www.website.com/");

<?php include(CFG_ROOT."includes/functions.php"); ?>

 

 

Archived

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

×
×
  • Create New...

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.