Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.