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.