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! 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"); 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/'; 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! Link to comment https://forums.phpfreaks.com/topic/77907-solved-includes/#findComment-394349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.