adamrg Posted March 17, 2006 Share Posted March 17, 2006 I can't figure out what's going wrong here. I'm using Ensim on Fedora and one of my sites isn't allowing me to include from a folder other than the one the current php script is in.include 'file.php'; //worksinclude 'directory/file.php'; //doesn't workinclude(getenv('DOCUMENT_ROOT').'/directory/file.php'); // doesn't workAny ideas?Thanks! Quote Link to comment Share on other sites More sharing options...
craygo Posted March 17, 2006 Share Posted March 17, 2006 you have to either reference the file from the current location or use the absolute pathexamplefile structure/home/wingnut/public_html/secondfoldif your file is in the public_html folder and you want to get file newscript.php in the secondfold then it would be[code]include('secondfold/newscript.php'); [/code]notice no starting slash, you only start the slash if you are doing absolute path[code]include('/home/wingnut/public_html/secondfold/newscript.php');[/code]lets say you are in the secondfold folder and want to reference a file in the base folder(public_html)[code]include('../myfile.php');[/code] the ../ will go back one level and work from therehope that helpsRay Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 17, 2006 Share Posted March 17, 2006 as mentioned above, include uses relative links. with that being said, i don't know why your "include 'directory/file.php';" example won't work. it seems straight forward as long as you're not referencing an absolute pathin your "directory". if you're after absolute paths, take a look at using virtual() instead, but it's not usually recommended. Quote Link to comment Share on other sites More sharing options...
adamrg Posted March 17, 2006 Author Share Posted March 17, 2006 Thanks for you help!I try to keep all my links reletive, and I'm still having an issue with my current script. I thought there must be some php setting or apache permissions that may be out of wack, but after building a simple test script, everything works just the way you guys explained.I don't understand why my script refuses to work.. ill have a drink and start again. Thanks... Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 17, 2006 Share Posted March 17, 2006 Is safe-mode enabled on this server?Ken 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.