foochuck Posted July 24, 2008 Share Posted July 24, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/116395-include-function-problem/ Share on other sites More sharing options...
samshel Posted July 24, 2008 Share Posted July 24, 2008 //define root path in some config. define("CFG_ROOT", "/var/www/html/www.website.com/"); <?php include(CFG_ROOT."includes/functions.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116395-include-function-problem/#findComment-598516 Share on other sites More sharing options...
Entanio Posted July 24, 2008 Share Posted July 24, 2008 Try putting: "/includes/... .php" Because I think the first "/" means web root. Quote Link to comment https://forums.phpfreaks.com/topic/116395-include-function-problem/#findComment-598518 Share on other sites More sharing options...
wildteen88 Posted July 24, 2008 Share Posted July 24, 2008 Try putting: "/includes/... .php" Because I think the first "/" means web root. no / to php means root of the filesystem, not your websites root directory. Quote Link to comment https://forums.phpfreaks.com/topic/116395-include-function-problem/#findComment-598827 Share on other sites More sharing options...
foochuck Posted July 24, 2008 Author Share Posted July 24, 2008 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"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116395-include-function-problem/#findComment-598847 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.