Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.