Tough question. Setting up modular code. Connections
Before we go further I want to add that I 'might' need to return an array of mysqli_connect(x.x.x.x) in my dbcon() function for the mysqli code to operate as intended but we'll get on to that later.
Here's what's going on so far. Had some help on this already so don't give me all the credit.
connect.php
function dbcon()
{
static $conn;
if (!$conn)
{
$host = 'localhost';
$username = 'x';
$password = 'x';
$dbname = 'x';
$conn = mysqli_connect($host , $username , $password ,$dbname);
}
return $conn;
}
On my class file this is how I am attempting to initiate it.
require_once("assets/configs/connect.php"); (); //Line 5 class myclass { Function (some functions) {
> Notice: Undefined variable: conn in C:xampphtdocscatsassetsincludescatclass.php on line 5 > Fatal error: Call to a cat function dbcon() on a non-object in C:xampphtdocscatsassetsincludescatclass.php on line 5
The 2nd Amendment, 1789 - The Original Homeland Security.
Gun control means never having to say, "I missed you."