// Locate config.php and set the basedir path $folder_level = ""; $i = 0; while (!file_exists($folder_level."config.php")) { $folder_level .= "../"; $i++; if ($i == 7) { die("config.php file not found"); } } define("BASEDIR", $folder_level); require_once BASEDIR."config.php";