putty Posted January 31, 2008 Share Posted January 31, 2008 Ok I have been running a script for several months now and all of a sudden I get a 500 error. I think this error corresponds to the server admin upgrading there version of php. I have tracked down the problem to my 'required_once' statements. the php script included by the 'required_once' is executing however no variables set in the included script are being passed back to the including script. Example. index.php <?php require_once('http://' . $_SERVER["HTTP_HOST"] . '/settings/dj-config.php');// Configuration and Global variable Declarations echo 'ROOT = ' . ROOT . '<br>'; echo '$root = ' . $root . '<br>'; ?> dj-config.php <?php define (ROOT, 'http://' . $_SERVER["HTTP_HOST"] . '/'); $root = 'Hello Would!'; ?> Run Script ROOT = ROOT $root = Both allow_url_fopen and allow_url_include are turned on, Are there any other php settings that could be causing this behaviour? Thanks, Levi Link to comment https://forums.phpfreaks.com/topic/88654-solved-required_once-problem/ Share on other sites More sharing options...
roopurt18 Posted January 31, 2008 Share Posted January 31, 2008 Just out of curiosity, if these files are on the same server, then why would you specify the path as a URL instead of a filepath? Link to comment https://forums.phpfreaks.com/topic/88654-solved-required_once-problem/#findComment-453998 Share on other sites More sharing options...
putty Posted January 31, 2008 Author Share Posted January 31, 2008 This application has a complex directory structure, I just found it an easy way to keep track of script paths Include('http://' . $_SERVER["HTTP_HOST"] . '/include/gui/tables.php) Is simpler to read than Include(../../../../include/gui/tables.php) i just like reading paths from the root derectory. I usualy include paths like this define('ABSPATH', dirname(__FILE__).'/');//setup in my config.php Include(ABSPATH . 'include/gui/tables.php)//include from in all other php files if you have a better approach I would love to see. PS, Problem solved PHP just need to be recompiled with apache. Link to comment https://forums.phpfreaks.com/topic/88654-solved-required_once-problem/#findComment-454012 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.