I am new to PHP/MySQL and I am experimenting with separating things to different pages and Include/Requiring them when needed. I am trying to make a database connection, but keep getting my "die" error.
OK Here is what I have:
At the top of the page I am trying to load I have:
require('app/application.php');
I have a page called "app.php"
// set the level of error reporting
error_reporting(E_ALL & ~E_NOTICE);
// load file, folder and database parameters
include('app/config.php');
// include the list of project filenames
require(DIR_APPLICATION . 'filenames.php');
// include the list of project database tables
require(DIR_APPLICATION . 'db_tables.php');
// include the database functions
require(DIR_FUNCTIONS . 'database.php');
// make a connection to the database... now
dbconn($strHostName, $strDbName, $strUserName, $strPassword) or die('Unable to connect to database server!');
Here is "config.php"
// Define the webserver and path parameters
define('DIR_APPLICATION', 'app/');
define('DIR_INCLUDES', 'inc/');
define('DIR_FUNCTIONS', DIR_APPLICATION . 'functions/');
define('DIR_CLASSES', DIR_APPLICATION . 'classes/');
define('DIR_MODULES', DIR_APPLICATION . 'modules/');
define('DIR_LANGUAGES', DIR_APPLICATION . 'languages/');
// Define image directories
define('DIR_IMAGES', 'images/');
define('DIR_ICONS', DIR_IMAGES . 'icons/');
Here is "database.php"
$strHostName = "localhost"; //e.g., "localhost".
$strDbName = "base_admin"; //Check if yours have prefixes.
$strUserName = "root"; //For the database, not your hosting account.
$strPassword = "";
function dbconn($strHostName, $strDbName, $strUserName, $strPassword) {
}
I just keep getting "Unable to connect to database server!"
What am I missing for petes sake.
Rab