Function global
Posted: Sat Dec 27, 2008 1:48 pm
I have this code:
On my local server, this works perfectly fine. On the dev server it will not get the $db_* variables from the config file. Is there a php setting I need to change to get this to work? AFAIK, this is a documented feature in the php manual. Don't make me explain, but my local server is php4 because our production server is php4...but our dev server is php5.
Code: Select all
require 'config.php';
function mysqlConnect()
{
global $db_host, $db_username, $db_password, $db_database;
$connection = mysql_connect($db_host, $db_username, $db_password)
or die('Failed to connect to MySQL. '.mysql_error());
$db = mysql_select_db($db_database, $connection)
or die('Failed to select the database.');
return $connection;
}