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 Using PHP with MySQL Querying the Database with PHP Avoiding Duplication

Seth Warner
Seth Warner
5,348 Points

Okay so up until I added the defining config file I was fine.

I never created an "INC" file. I am currently doing this all on sublime within a folder and yes it is running with mamp. Everything was fine up until I added the following, now its just timing out and not loading.

"mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";port=" . DB_PORT,DB_USER,DB_PASS

I have another file in the project named config.file and it has this inside it.

define("BASE_URL","/");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/");

define("DB_HOST","localhost");
define("DB_NAME","Databaseone");
define("DB_PORT","3306");
define("DB_USER","root");
define("DB_PASS","root");

What is causing this to "time out", not load.

Seth Warner
Seth Warner
5,348 Points

Okay I got it, I had to require("config.php"); in order for it to know that the

"mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";port=" . DB_PORT,DB_USER,DB_PASS

were

define("BASE_URL","/"); define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/");

define("DB_HOST","localhost"); define("DB_NAME","Databaseone"); define("DB_PORT","3306"); define("DB_USER","root"); define("DB_PASS","root");

In the config.php file. That should be mentioned.