I have a database connection file in my web application and for some reason the server is trying to connect to the location of: ***.**.**.215
for the ip address rather than: ***.**.**.222
which is what is typed in the file. The code is below:
<?php
// Configure the following items to match your database!
// Database Location
$location = '***.**.**.222';
// Database Name
$name = '';
// Database Username
$username = '';
// Database Password
$Password = '';
// Do not alter anything beyond this line!
// Create connection
$con=mysqli_connect($location,$username,$password,$name);
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
Google Chrome shows this exact error message: I removed the credentials from it.
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'username'@'***.**.**.215' (using password: NO) in /home/www/hiddenforsecurity/shop/config/connect.php on line 20
Failed to connect to MySQL: Access denied for user 'username'@'***.**.**.215' (using password: NO)
I'm not sure what in the world to do or what is wrong, when I replace $location
in the $con
with the actual ip address, it works perfect. It's just when I use the variable $location
that it doesn't work.
I removed important private credentials from this question. Sorry hackers.