Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Integrating PHP with Databases Databases and PHP Getting Started with PDO

Unable to connect the database by using and show fatal error

Access denied for user 'root'@'localhost' (using password: YES) I am not sure what is the error of above after I trying to access http://localhost/integrating_php_with_databases_s1v1/inc/connection.php

I am wondering is it the error telling me that I should set the password as YES? But I thought that we are able to reset the password?

I did create a config.php and a connection.php

config.php

<?php
define("BASE_URL", "localhost/integrating_php_with_databases_s1v1");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/" . "integrating_php_with_databases_s1v1/");

define("DB_HOST","localhost");
define("DB_NAME","database");
define("DB_USER","root");
define("DB_PASS","YES");
define("DB_PORT", "8889");
?>

connection.php

<?php
require_once('../config.php');

$db = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";port=" . DB_PORT, DB_USER, DB_PASS);

echo "Connected to the database";
?>

Any help and explanation will be appreciated.