-2

I want to connect 2 diffrent DB, but I get that error:

Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user '*username*'@'localhost' (using password: YES) in......

my code:

$mysqli2 = new mysqli('localhost',$db_user,$db_pass, $db_name);
$mysqli2 = new mysqli('localhost',$db_user2,$db_pass2, $db_name2);

And I try to excute queries like this:

$result=$mysqli->query("select ......
$result=$mysqli2->query("select ......

How can I fix this?

Dirty-flow
  • 2,306
  • 11
  • 30
  • 49
DevShaked
  • 1
  • 1

3 Answers3

1

Your username or password is wrong.

Glitch Desire
  • 14,632
  • 7
  • 43
  • 55
1

Your mysql user may not have the right privileges to connect over the network.

See here : How to grant remote access permissions to mysql server for user?

Community
  • 1
  • 1
Tom Macdonald
  • 6,433
  • 7
  • 39
  • 59
0

check password and adress and username

use next code to connect

$connect1 = new mysqli(...);
$connect2 = new mysqli()
if ($connect1->connect_error)
  echo "error in 1 connection message: " . $connect1->connect_error;
if ($connect2->connect_error)
  echo "error in 2 connection message: " . $connect2->connect_error;

where you see a problem ?

smpl
  • 26
  • 2