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?

  • Should work. Similarly, in the real code you have no typos? - rjhdby
  • I tried to log in with the password, the user becomes in place. problem in the empty value in the string password how to solve? - Artberg
  • The mysqli problem is not relevant. Set error_reporting (E_ALL) and see where you lose your parameters - Ipatyev
  • empty value for a password nothing to do with. You have a problem with the user name - Ipatiev
  • one
    Actually there is such a bug. bugs.php.net/bug.php?id=67026 , bugs.php.net/bug.php?id=46457 - rjhdby

0