jeff5656 Posted July 25, 2010 Share Posted July 25, 2010 Having problems pointing to where files are. Is this the root?: include "../connectdb.php"; That file is locate din the root. If I am already in the root when I include that statment, the file isn't found. If I use the above code while I am in the subdirectory hello, (root/hello), it works. I use this in every page, so I think I need a way to point to the absolute root, not relative. Link to comment https://forums.phpfreaks.com/topic/208797-which-is-the-root/ Share on other sites More sharing options...
Fricti0n Posted July 25, 2010 Share Posted July 25, 2010 Try if this works <?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/connectdb.php"; include_once($path); ?> I would recomend to make a config folder to have all your function- and mysql- scripts in - Fricti0n Link to comment https://forums.phpfreaks.com/topic/208797-which-is-the-root/#findComment-1090782 Share on other sites More sharing options...
jeff5656 Posted July 29, 2010 Author Share Posted July 29, 2010 Actually that doesn't work. The $_SERVER['DOCUMENT_ROOT'] that I get back is not the actual location where my index file is. I think this link explains why: http://www.helicron.net/php/ Perhaps my host is not using apache (since above only works in apache). In any case, is there a way to solve this with relative paths? I thought that if I was in a subdirectory and I want to point to another subdirectory I would point to include "../anotherdirectory/filename.php"; but that doesn't work. Obviously the best solutions would be some way to automatically determine the root directory (regardless of whether the host has apache). Any ideas? Link to comment https://forums.phpfreaks.com/topic/208797-which-is-the-root/#findComment-1092584 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.