Jump to content

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"); ?>

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.