Jump to content

[SOLVED] includes


newbie69

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.