DR.Wong
01-25-2012, 07:47 AM
Hi all!
I am having a problem including a file inside of a function.
This works :
function queryDB($query)
{
include '../includes/config.php';
}
And this does not :
$configFileLocation=$_SERVER['DOCUMENT_ROOT']."/includes/config.php";
function queryDB($query)
{
include $configFileLocation;
}
Neither does this :
function queryDB($query)
{
include $_SERVER['DOCUMENT_ROOT']."/includes/config.php";
}
If the config file is included using the $configFileLocation variable outside of the function, the variables in the config.php file are available. When included inside of the function (using via $configFileLocation), they are not.
What am I missing?
Thanks a lot.
I am having a problem including a file inside of a function.
This works :
function queryDB($query)
{
include '../includes/config.php';
}
And this does not :
$configFileLocation=$_SERVER['DOCUMENT_ROOT']."/includes/config.php";
function queryDB($query)
{
include $configFileLocation;
}
Neither does this :
function queryDB($query)
{
include $_SERVER['DOCUMENT_ROOT']."/includes/config.php";
}
If the config file is included using the $configFileLocation variable outside of the function, the variables in the config.php file are available. When included inside of the function (using via $configFileLocation), they are not.
What am I missing?
Thanks a lot.