Help get this topic noticed by sharing it on Twitter, Facebook, or email.

MySql Error Message for Host, Database, Username and Password.


I've read the entire book (Learning PHP, MySQL & JavaScript, 4th Edition) and reread several chapters I didn't completely understand. Right now, I'm attempting to build a sample social network right now.

Here's an error that's been troubling me for a day or two. I'll probably reread a few sections in the book to figure it out myself later on.

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'commune'@'localhost' (using password: YES) in /Applications/XAMPP/xamppfiles/htdocs/dev/functions.php on line 8
Access denied for user 'commune'@'localhost' (using password: YES)

Here's the code for the "functions.php".

connect_error) die($connection->connect_error);

function createTable($name, $query)
queryMysql("CREATE TABLE IF NOT EXIST $name($query)");
echo "Table '$name' created or already exists.

function queryMysql($query)
global $connection;
$result = $connection->query($query);
if (!$result) die($connection->error);
return $result;

function destroySession()

if (session_id() != "" || isset($_COOKIE[session_name()]))
setcookie(session_name(), '', time()-2592000, '/');


function sanitizeString($var)
global $connection;
$var = strip_tags($var);
$var = htmlentities($var);
$var = stripslashes($var);
return $connection->real_escape_string($var);


This is pretty much the exact same code from the book. Eventually when I get better I'll write my code.

So what is the problem here? Thank You
1 person has
this question