adam291086 Posted December 13, 2007 Share Posted December 13, 2007 OK here is my problem. I have a domain that points to a specific folder on my host. How do i include php file that are outside that folder. If i use ../foldername it goes to the route of that folder it points to, instead of the route of the server. I hope this makes sense. Adam Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 13, 2007 Share Posted December 13, 2007 The best way to handle your include folders is a file of constants in your root folder <?php //All constants used on the site define("ROOT",$_SERVER['DOCUMENT_ROOT']."/ROOT/"); define("BASE", "http://mysite.com/FOLDERROOT/"); define("SCRIPTS", ROOT."scripts/"); define("SUB_FOLDER", BASE."source/"); define("GRAPHICS", BASE."graphics/"); define("SOURCES", BASE."sources/"); define("IMAGES", BASE."images/"); define("CSS", BASE."css/"); define("EXT", ".php"); ?> So when you go to include stuff on your server first track down this file (only context you will need a path for) <?php require_once("../constants.php"); require_once(SCRIPTS."/functions.php"); require_once(SCRIPTS."/sql_functions.php"); ?> That way if you move stuff everything updates. The ROOT is for internal pointers the BASE is for urls and images for html linking Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 13, 2007 Author Share Posted December 13, 2007 Yeah but how do i get around the issue of the pointing server. The folder the server points too is its document root. How do i include file outside that folder? BTW cooldude832 the delete script you help me with the other works wounderfully. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 You will have to use a absolute path where you folder is on the server itself. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 13, 2007 Share Posted December 13, 2007 so you are trying to link to data outside your domain? are you trying to do something like: root: Domain 1: index file for domain 1 Want index to include the include in domain 3 Domain 2: index file for domain 2 Domain 3: index file for domain3 include File for domain 1 Domain 4: index file for domain 4 If so you will probably need to go remote and use file_get_contents of the included file Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 13, 2007 Author Share Posted December 13, 2007 Well i have all my php in one file. For example my database config.php. I want to be able to store this file once. At the moment i am include '../database/config.php'. This works fine else where. But in the folder where the server points to it cant find the file. How would i use file_get_contents? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 13, 2007 Share Posted December 13, 2007 well if you are linking to a file in its own folder you don't include teh ../ jsut gives its file name, file_get_contents will only work for text outputs like cms or images Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 13, 2007 Author Share Posted December 13, 2007 i am not linking to a file in it own folder. I am linking outside a folder. Which is done correctly. But the domain that point to a specific folder on my host treats this folder as document root. Therefore ../ doesn't mean host root anymore it means root of the folder. Quote Link to comment 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.