I usually do it this way because I like to use a $_CONFIG array. However, if you only have primitive values to store it would be simpler to use defines:
Code:
define('DBUSER', 'root'); // Why the heck are you using the root account?
define('DBHOST', 'localhost');
define('DBPASSWORD', 'somepassword');
Code:
mysql_connect(DBHOST, DBUSER, DBPASSWORD);
If you use global variables in a function, you have to worry about writing
Code:
global $dbhost, $dbuser, $dbpassword;
all the time. Defines remove the necessity for this.
Bookmarks