We have a standard connection form:
$connection = mysqli_connect("127.0.0.1", "root", "", "my_db"); Connect without errors.
I make 2 files
1) db.php
$connection = mysqli_connect( $config['db']['server'], $config['db']['username'], $config['db']['password'], $config['db']['name'] ); 2) config.php
$config = array( 'title' => '#', 'vk_url' => '#', 'db' => array( 'server' => '127.0.0.1', 'username' => 'root', 'password' => '', 'name' => 'my_db' ) ); require "db.php"; essentially the same thing, only the data is taken from the config.php dump
{ ["server"]=> string(9) "localhost" ["username"]=> string(4) "root" ["password"]=> string(0) "" ["name"]=> string(6) "my_db" } } te it would seem everything is fine
my version does not allow me to the database for the reason:
Warning: mysqli_connect (): (HY000 / 1045): Access denied for user '' @ 'localhost' (using password: NO) in E: \ OpenServer \ OpenServer \ domains \ localhost \ mysite \ includs \ db.php on line 6 Connection error! Access denied for user '' @ 'localhost' (using password: NO)
Access denied for user '' @ 'localhost'
Here, as I understand it, the user complains as an empty value, why is it so?