Hey guys, I’m stuck with a MySQL connection problem. When I try to run my PHP script, I get these errors:
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /var/www/html/frontend/htdocs/cfg.php on line 2
Warning: mysqli_query(): Couldn't fetch mysqli in /var/www/html/frontend/htdocs/cfg.php on line 4
Here’s my cfg.php file:
<?php
$db = new DatabaseConnection();
$config = new Configuration();
if ($_SERVER['SERVER_NAME'] == 'localhost') {
$config->setBaseUrl('http://localhost/');
$config->setApiUrl($config->getBaseUrl() + 'api/htdocs/api.php');
$config->setAuthLoginUrl($config->getBaseUrl() + 'auth/htdocs/login.php');
$config->setAuthVerifyTokenUrl($config->getBaseUrl() + 'auth/htdocs/verify_token.php');
} else {
$config->setBaseUrl('http://example.com');
$config->setApiUrl('http://api.example.com/api.php');
$config->setAuthLoginUrl('http://auth.example.com/login.php');
$config->setAuthVerifyTokenUrl('http://auth.example.com/verify_token.php');
}
?>
I can’t figure out what’s wrong. Any ideas on how to fix this? Thanks!