I am having some trouble. So I am trying to connect to my database using MySQLi, but I am getting this error:
Warning: mysqli::mysqli(): (28000/1045): Acces
The reason of the error is here:
class Routing {
public function __construct($route) {
$this->users = new Users();//<-?
$this->route = $route;
}
You are not passing a parameter to Users.__construct($db)
Define an array with credentials and pass is like this:
class Routing {
public function __construct($route) {
$db = array();
$db['host'] = 'localhost';
$db['user'] = 'venge_main';
$db['pass'] = 'fakepassword';
$db['name'] = 'venge_panel';
$this->users = new Users($db);
$this->route = $route;
}
Or use a global $db variable instead of defining it locally, like I did. But you must pass it to constructor when creating Users object.
$users = new Users($database);
I think, it must be:
$users = new Users($db);
If $db is defined in that file.