Jump to content

mysqli connect fails with correct parameters


PHPremote

Recommended Posts

The following standard code is not allowing access to the MySQL database indicated:

	// declare database validation variables
	$servername = "localhost";
	$username = "toughnerd";
	$password = "frustrated";
	$dbname = "workforaliving2";

	// Create connection
	$conn = new mysqli($servername, $username, $password, $dbname);

	// Check connection
	if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
	}
		echo "Connected successfully";

Here is the error message:

Quote

Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'toughnerd'@'localhost' (using password: YES) in C:\xampp\htdocs\frameworkinphpsauce\testingOfFramework\askQuery_function.php on line 43
Connection failed: Access denied for user 'toughnerd'@'localhost' (using password: YES)

The server name, username, password, and database name are correct, defined in phpAdmin as needed.

I do understand that "(using password: YES)" just means a password is being used.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...