I have db.php with the following code.
<?php
$dbHost = "localhost";
$dbUser = "root";
$dbPass = "password";
$dbName = "test";
$databaseLink = new mysqli ($dbHost, $dbUser, $dbPass);
if($databaseLink)
{
mysqli_select_db($databaseLink,$dbName);
}
?>
which I usually import on to other php page like this
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/core/include/db.php";
?>
and works fine. I can start querying using $databaseLink. But there is one page where its not working. But if I explicitly define the connection like this $databaseLink= mysqli_connect("localhost", "root", "password", "test"); it works. There are other php files in the same directory which has no issues.
I have tried
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/core/include/db.php";
global($databaseLink);
?>
But that does not seem to work too. I have looked it up online for examples but can find any help.
require $path;(or better yetrequire_once)require_once $pathtodbinstead?include_once($path);orrequire_once($path)