I have this line of code:
$mysqli = new mysqli("localhost", "user", "pass", "db");
I'm using XAMPP for the Apache and MySQL. If I use the line above it throws the following error:
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'user'@'localhost' (using password: YES) in C:\xampp\htdocs\xo\php\connect.php on line 2
Failed to connect to MySQL: (1045) Access denied for user 'user'@'localhost' (using password: YES)
Warning: main(): Couldn't fetch mysqli in C:\xampp\htdocs\xo\php\connect.php on line 6
It's the same if I replace localhost with 127.0.0.1(I tried). But if I use my internal network IP(in this case 192.168.1.101) instead of localhost it connects successfully.