newbie69 Posted November 19, 2007 Share Posted November 19, 2007 Hi Everyone, I have the following state ment: include($_SERVER['DOCUMENT_ROOT']."/admin/php_scripts/_dbconnections.php"); Now for testing purposes I created my own variable called $documentRoot that essentially has the following assigned to it: $documentRoot = "$_SERVER['DOCUMENT_ROOT']."/csiweb/"; Now i want to do the following: include($documentRoot."admin/php_scripts/_dbconnections.php"); but php throw the following error: "Warning: include(/admin/php_scripts/_dbconnections.php) [function.include]: failed to open stream: No such file or directory " Does anyone now how i can get my $documentRoot variable to be displayed within the include function? Thanks in advanced! Quote Link to comment https://forums.phpfreaks.com/topic/77907-solved-includes/ Share on other sites More sharing options...
rajivgonsalves Posted November 19, 2007 Share Posted November 19, 2007 you have to mention it as a global global $documentRoot; $documentRoot = "$_SERVER['DOCUMENT_ROOT']."/csiweb/"; and in your function too global $documentRoot; include($documentRoot."admin/php_scripts/_dbconnections.php"); I would suggest the following code define("SITE_DOCUMENT_ROOT","$_SERVER['DOCUMENT_ROOT']."/csiweb/"); and in your function include(SITE_DOCUMENT_ROOT.admin/php_scripts/_dbconnections.php"); Quote Link to comment https://forums.phpfreaks.com/topic/77907-solved-includes/#findComment-394331 Share on other sites More sharing options...
~n[EO]n~ Posted November 19, 2007 Share Posted November 19, 2007 It should be $documentRoot = $_SERVER['DOCUMENT_ROOT'].'/csiweb/'; Quote Link to comment https://forums.phpfreaks.com/topic/77907-solved-includes/#findComment-394332 Share on other sites More sharing options...
newbie69 Posted November 19, 2007 Author Share Posted November 19, 2007 Hi rajivgonsalves This work perfectly, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/77907-solved-includes/#findComment-394349 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.