mkosmosports Posted February 3, 2007 Share Posted February 3, 2007 I want to use the include function on a file thats in the top-level directory of my site. I call on that from many sub-level directories, so whats the syntax to always call on that file, which is in the top-level directory? Ive tried: include ("../dbconnect.php");, include ("/dbconnect.php"); Doesnt work... Quote Link to comment https://forums.phpfreaks.com/topic/36923-silly-question/ Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 can you roughly list out the postitions? like: test.php//root test/test.php//subdirectory. something like this will help Ted Quote Link to comment https://forums.phpfreaks.com/topic/36923-silly-question/#findComment-176134 Share on other sites More sharing options...
mkosmosports Posted February 3, 2007 Author Share Posted February 3, 2007 Well, dbconnect.php is in the root folder of the site. I then have another file in rootfolder/maincontent that needs to include dbconnect.php. Quote Link to comment https://forums.phpfreaks.com/topic/36923-silly-question/#findComment-176139 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 if both of them doesnt work, have you tried "http://domain.com/dbconnect.php"? Quote Link to comment https://forums.phpfreaks.com/topic/36923-silly-question/#findComment-176144 Share on other sites More sharing options...
mkosmosports Posted February 3, 2007 Author Share Posted February 3, 2007 Yeah, that works. Thanks Ted Chou. I did have to enable URL file-access in the server configuration. After reading up on php.net, turns out php doesnt handle including files from other directories very well. A user posted this question there: "Why are the included files not looked up relative from the file that includes them and then in the include path? This would be a behavior like in all other languages." Quote Link to comment https://forums.phpfreaks.com/topic/36923-silly-question/#findComment-176148 Share on other sites More sharing options...
ted_chou12 Posted February 3, 2007 Share Posted February 3, 2007 I dont know actually, i always preform trail and error when there are errors. Ted Quote Link to comment https://forums.phpfreaks.com/topic/36923-silly-question/#findComment-176150 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.