tags:

views:

21

answers:

2

Below is my code that I am using. I know that the details are correct 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();
}
A: 

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?

coreyward
I am using the same login details as the one that works!
steve
A: 

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.

Nick F