MySQLIi is not accepting my database login details
Below is my code that I am using. I know that the details are correct 开发者_Python百科as they are identical to another page that connects to the database fine. However with this code I get the error:
Access denied for user 'un'@'localhost' (using password: YES)
. Can anyone tell me what it is i'm doing wrong? Thanks
$hostname = 'localhost';
$username = 'un';
$password = 'pw';
$dbname = 'db';
$user = 'admin_uk';
$password = 'r04ryuk';
if($connection = mysqli_connect($hostname, $username, $password, $dbname)){
echo 'slup';
}else{
echo mysqli_connect_error();
}
What's different between this snippet and the one that works fine? Are they both run locally? Same user? Same password? Same database?
I'm guessing you're having a problem with permissions. Maybe the 'un' user doesn't have access to the 'db' database?
You should check to make sure that the 'un' user is actually setup to connect to 'localhost'. I've had a couple problems where I had to tweak those.
After that, make sure to FLUSH PRIVILEGES after any changes.
精彩评论