I have this line of code:
$mysqli = new mysqli("localhost", "user", "pass", "db");
I use XAMPP for Apache and MySQL. If I use the line above, it causes 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
Same thing if I replace localhost 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 successfully connects.
source share