Wondering if it is possible to include two mysqli connection include php files on the same page.
I have a basic site I am using to learn/develop in php with mysql. I have one database for storing user information and another for website specific information. I can use both independently from each other without any issues.
Config.php:
DEFINE("HOST", "127.0.0.1");
DEFINE("USER","root");
DEFINE("PASS","");
DEFINE("DB","sv");
connect.php:
include_once 'config.php';
$mysqli = new mysqli(HOST, USER, PASS, DB);
sec_config.php:
define("HOST", "127.0.0.1");
define("USER", "sec_user");
define("PASSWORD", "");
define("DATABASE", "svn");
sec_connect.php:
include_once 'sec_config.php'; // As functions.php is not included
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
My php pages can successfully query and display data from these connections. My index.php currently contained included the sec_connect, I am trying to add another php page which (within itself) includes
include_once("connect.php");
When I try and run the page I receive
mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: No such host is known.
mysqli::mysqli(): (HY000/2002): php_network_getaddresses: ...as above
mysqli::prepare(): Couldn't fetch mysqli in
Fatal error: Call to a member function bind_param() on a non-object in
I have simply commented out the above include_once to get everything working again.
I am using windows with xamp for dev, I have tried accessing via localhost and my ip address and I receive the same error. I have tried editing the hosts file and I have also tried amending the values in the connect files to be unique (changed back as it didnt help).
Hopefully this is the righ question to ask: Is it possible to include two mysqli database connections via different includes from my index.php page?