HawkCode Posted July 10, 2007 Share Posted July 10, 2007 Hi, I have a php file included in many differant files at all differant levels in the directory structure. The problem I have is if a condition is met, it passes control to another php file in the same directory. However that file is not found by all files in the other directorys. home/file1.php <---------- Includes inc/file2.php ----> inc/file2.php home/file2.php passes control to inc/file2.php >>>>> This works home/dir1/file1a.php <---------- Includes inc/file2.php ----> ../inc/file2.php home/file2.php passes control to inc/file2.php >>>>> This doesn't work. How can I have the include file's call to files in the same directory no matter where the file that included it is? Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted July 10, 2007 Share Posted July 10, 2007 Dont use relative paths. Start your base path from $_SERVER['DOCUMENT_ROOT']. Quote Link to comment Share on other sites More sharing options...
HawkCode Posted July 10, 2007 Author Share Posted July 10, 2007 I'm getting this error: /var/www/localhost/htdocs/AccessControl/Login.php was not found on this server. Here's the line: $MM_restrictGoTo = $_SERVER['DOCUMENT_ROOT'] . "/AccessControl/Login.php"; This works: $MM_restrictGoTo = "AccessControl/Login.php"; THe file including it is in directory above AccessControl THanks Quote Link to comment Share on other sites More sharing options...
HawkCode Posted July 11, 2007 Author Share Posted July 11, 2007 I tried using Absolute path using this: define ("ROOT", dirname(__FILE__)); Got this error: The requested URL /var/www/aspe.org/htdocs/AccessControl/Login.php was not found on this server. This is the code calling it: if ($MinAccessLevel > 0) { $MM_restrictGoTo = ROOT . "/AccessControl/Login.php"; if (!((isset($_SESSION['LoginID'])) && (isAuthorized("",$MinAccessLevel, $_SESSION['LoginID'], $_SESSION['AccessLevel'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header(sprintf("Location: %s", $MM_restrictGoTo . SID )); exit; } This is code that was generated by Dreamweaver and I copied it. Thanks 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.