ricky spires Posted September 6, 2011 Share Posted September 6, 2011 hello. i want to create an oop website on my localhost but im having trouble getting the initialize file to find my config file. if i point my browser to my local host my index page works fine because it does not need the initialize file at this stage, but if i point my browser to my admin index (http://localhost/djsonrotation/admin/) i get this error Warning: require_once() [function.require-once]: URL file-access is disabled in the server configuration in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 9 Warning: require_once(http://localhost/djsonrotation/config.php) [function.require-once]: failed to open stream: no suitable wrapper could be found in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 9 Fatal error: require_once() [function.require]: Failed opening required 'http://localhost/djsonrotation/config.php' (include_path='.:/Applications/MAMP/htdocs/php5/lib/php') in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 9 the initialize file is basically 1 place that points to lots of different places and mine looks like this: <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_DOMAIN') ? null : define('SITE_DOMAIN', 'http://localhost/djsonrotation'); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_DOMAIN.DS.'includes'); defined('CSS_PATH') ? null : define('CSS_PATH', SITE_DOMAIN.DS.'css'); require_once(SITE_DOMAIN.DS.'config.php'); require_once(SITE_DOMAIN.DS."functions.php"); require_once(SITE_DOMAIN.DS."session.php"); require_once(SITE_DOMAIN.DS."database.php"); require_once(SITE_DOMAIN.DS."user.php"); ?> this is the config file its looking for: <?PHP defined('DB_SERVER') ? null : define("DB_SERVER", "localhost"); defined('DB_USER') ? null : define("DB_USER", "admin"); defined('DB_PASS') ? null : define("DB_PASS", "*************"); defined('DB_NAME') ? null : define("DB_NAME", "djsonrotation"); ?> this is how my mamp is set up PORTS - 80 - 3306 PHP - 5 APACHE - /Applications/MAMP/htdocs this is where my file are located on my wwwroot /index.php /includes/initialize.php /includes/config.php /admin/index.php this is the line of code calling the initialize on /admin/index.php require_once("../includes/initialize.php"); thanks rick Link to comment https://forums.phpfreaks.com/topic/246521-cant-connect-to-configphp-using-initializephp-in-localhost/ Share on other sites More sharing options...
voip03 Posted September 6, 2011 Share Posted September 6, 2011 It may help http://www.phpfreaks.com/forums/index.php?topic=343181.msg1619002#msg1619002 Link to comment https://forums.phpfreaks.com/topic/246521-cant-connect-to-configphp-using-initializephp-in-localhost/#findComment-1265855 Share on other sites More sharing options...
flappy_warbucks Posted September 6, 2011 Share Posted September 6, 2011 It looks like you're calling the file using the domain path, and not the servers directory path. defined('SITE_DOMAIN') ? null : define('SITE_DOMAIN', 'http://localhost/djsonrotation'); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_DOMAIN.DS.'includes'); defined('CSS_PATH') ? null : define('CSS_PATH', SITE_DOMAIN.DS.'css'); require_once(SITE_DOMAIN.DS.'config.php'); if you look, you can see that the require_once function is trying to call "http://localhost/djsonrotation/config.php" when you really need it to call the file relative to the hard drive location, and not relative to the domain location. I would change that to: defined('SITE_DOMAIN') ? null : define('SITE_DOMAIN', 'http://localhost/djsonrotation'); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_DOMAIN.DS.'includes'); defined('CSS_PATH') ? null : define('CSS_PATH', SITE_DOMAIN.DS.'css'); require_once(SITE_ROOT.DS.'includes/config.php'); Link to comment https://forums.phpfreaks.com/topic/246521-cant-connect-to-configphp-using-initializephp-in-localhost/#findComment-1265856 Share on other sites More sharing options...
ricky spires Posted September 6, 2011 Author Share Posted September 6, 2011 hello. thanks for your replies. i just tried this but it didnt work <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_DOMAIN') ? null : define('SITE_DOMAIN', 'http://localhost/djsonrotation'); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); require_once(SITE_ROOT.DS.'includes/config.php'); require_once(SITE_ROOT.DS."includes/functions.php"); require_once(SITE_ROOT.DS."includes/session.php"); require_once(SITE_ROOT.DS."includes/database.php"); require_once(SITE_ROOT.DS."includes/user.php"); ?> i got this error: Warning: require_once(/Applications/MAMP/htdocs/includes/config.php) [function.require-once]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 7 Fatal error: require_once() [function.require]: Failed opening required '/Applications/MAMP/htdocs/includes/config.php' (include_path='.:/Applications/MAMP/htdocs/php5/lib/php') in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 7 Link to comment https://forums.phpfreaks.com/topic/246521-cant-connect-to-configphp-using-initializephp-in-localhost/#findComment-1265865 Share on other sites More sharing options...
flappy_warbucks Posted September 6, 2011 Share Posted September 6, 2011 Warning: require_once(/Applications/MAMP/htdocs/includes/config.php) [function.require-once]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 7 Fatal error: require_once() [function.require]: Failed opening required '/Applications/MAMP/htdocs/includes/config.php' (include_path='.:/Applications/MAMP/htdocs/php5/lib/php') in /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php on line 7 Read the error: /Applications/MAMP/htdocs/includes/config.php that is where it is saying it's looking. /Applications/MAMP/htdocs/djsonrotation/includes/initialize.php That is where the script is. So: <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_DOMAIN') ? null : define('SITE_DOMAIN', 'http://localhost/djsonrotation'); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); require_once(SITE_ROOT.DS.'djsonrotation/includes/config.php'); require_once(SITE_ROOT.DS."djsonrotation/includes/functions.php"); require_once(SITE_ROOT.DS."djsonrotation/includes/session.php"); require_once(SITE_ROOT.DS."djsonrotation/includes/database.php"); require_once(SITE_ROOT.DS."djsonrotation/includes/user.php"); ?> Try that. Link to comment https://forums.phpfreaks.com/topic/246521-cant-connect-to-configphp-using-initializephp-in-localhost/#findComment-1265869 Share on other sites More sharing options...
ricky spires Posted September 6, 2011 Author Share Posted September 6, 2011 hello. great. that seemed to work. the only thing is, i have a new error. i will try a couple of things and if i cant get it working ill come back to you later. thanks bye for now i tried it but no go <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_DOMAIN') ? null : define('SITE_DOMAIN', 'http://localhost/djsonrotation'); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); require_once(SITE_ROOT.DS.'djsonrotation/includes/config.php'); require_once(SITE_ROOT.DS."djsonrotation/includes/functions.php"); require_once(SITE_ROOT.DS."djsonrotation/includes/session.php"); require_once(SITE_ROOT.DS."djsonrotation/includes/database.php"); require_once(SITE_ROOT.DS."djsonrotation/includes/user.php"); ?> this is the new error : Notice: Use of undefined constant LIB_PATH - assumed 'LIB_PATH' in /Applications/MAMP/htdocs/djsonrotation/includes/database.php on line 3 Warning: require_once(LIB_PATH/config.php) [function.require-once]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/djsonrotation/includes/database.php on line 3 Fatal error: require_once() [function.require]: Failed opening required 'LIB_PATH/config.php' (include_path='.:/Applications/MAMP/htdocs/php5/lib/php') in /Applications/MAMP/htdocs/djsonrotation/includes/database.php on line 3 Link to comment https://forums.phpfreaks.com/topic/246521-cant-connect-to-configphp-using-initializephp-in-localhost/#findComment-1265876 Share on other sites More sharing options...
flappy_warbucks Posted September 6, 2011 Share Posted September 6, 2011 If you read the error it tells you exactly what the problem is. LIB_PATH is not defined Link to comment https://forums.phpfreaks.com/topic/246521-cant-connect-to-configphp-using-initializephp-in-localhost/#findComment-1265877 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.