Could not connect to MYSQL.... ?

Right so, I have created a set user to access this database - but this user was not able to. I then tested with root, and this too was not able to access the database.

I get the following message when trying to connect:

Could not conenct to MYSQL: Access denied for user ‘root’@‘localhost’ (using password: YES)

Here is my script:

<?php # script 8.2 - mysqli_connect.php //This file contains the database access information. //This file also establishes a connection to MYSQL // and selects the database. //Set the database access information as constants: DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', '******'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'sitename'); // Make the connection: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_Password, DB_NAME) OR die('Could not conenct to MYSQL: ' . mysqli_connect_error() ); ?>

Any ideas? :frowning: please help!.. Thanks!

DEFINE (‘DB_NAME’, ‘sitename’);

here it should not be the site name, it should be the database name.

Trouble is, is that sitename IS the database name :frowning:

When you wrote this bit:
DEFINE (‘DB_USER’, ‘root’);
DEFINE (‘DB_PASSWORD’, ‘******’);
DEFINE (‘DB_HOST’, ‘localhost’);
DEFINE (‘DB_NAME’, ‘sitename’);
you used all capitol letters…
then when you wrote this bit:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_Password, DB_NAME)
you use lowecase on the password.


cheers… your a legend! :smiley:

Your welcome ;D

Sponsor our Newsletter | Privacy Policy | Terms of Service