I have a problem with my config.php file which returns error like this.
PHP Notice: Use of undefined constant for M_DATABASE_SERVER, M_DATABASE_USER, M_DATABASE_PASSWORD, M_DATABASE_NAME, M_ENV_SITE_ROOT and M_ENV_SITE_URL.
I have browsed for other answers which says that the answer might lie with the adding quotes, so I added them. Example: define('M_DATABASE_SERVER',$db_host); However, it does not work.
Here's my code, I hope someone can assist. Thank you.
<?php
$db_host = "localhost";
$db_user = "myname";
$db_pass = "mypassword";
$db_name = "mydatabase";
define('M_DATABASE_SERVER',$db_host);
define('M_DATABASE_USER',$db_user);
define('M_DATABASE_PASSWORD',$db_pass);
define('M_DATABASE_NAME',$db_name);
define('M_ENV_SITE_ROOT', $_SERVER["DOCUMENT_ROOT"]);
define('M_ENV_SITE_URL', "http://".$_SERVER["HTTP_HOST"]);
//define(M_ENV_SITE_ROOT, SITE_ROOT_PLACEHOLDER);
//define(M_ENV_SITE_URL, SITE_URL_PLACEHOLDER);
// Autoload classes
function __autoload($classname)
{
require('M_ENV_SITE_ROOT'.'/include/'.$classname.'.class.php');
}
// An alternative
//array_walk(glob('./include/*.class.php'),create_function('$v,$i', 'return require_once($v);'));
// Open database
$mysql_err = false;
$db = new sql();
if(!$db->connect('M_DATABASE_SERVER', 'M_DATABASE_USER', 'M_DATABASE_PASSWORD', 'M_DATABASE_NAME'))
{
$mysql_err = "Could not connect to database.";
}
// Represents all post and get variables
$post = new post($db);
$get = new get($db);
// Initialize current admin user
$user = new user($db);
// Initialize config object
$config = new config($db);
?>