So something like this? function database_connection() { global = $cfg['hostname'],$cfg['username'],$cfg['password']; @mysql_connect($cfg['hostname'],$cfg['username'],$cfg['password']); @mysql_select_database($cfg['database']); }
Or could I do an entire array like so...
function database_connection() { global = $cfg; @mysql_connect($cfg['hostname'],$cfg['username'],$cfg['password']); @mysql_select_database($cfg['database']); }
??? Stupid question I know...
Geir Pedersen - Activio As wrote:
$cfg['hostname'] = "www.server.com"; // Server domain or ip address $cfg['username'] = "username"; // Database user name $cfg['password'] = "password"; // Database password $cfg['bugemail'] = "[EMAIL PROTECTED]";
Then do something like this:
function database_connection() { @mysql_connect($cfg[hostname],$cfg[username],$cfg[password]); @mysql_select_database($cfg[database]); }
1) You have to declare $cfg as a global variable in your data_connection() function. PHP differs from C with respect to how you access global variables from within functions. Read about global variables here http://www.php.net/manual/en/language.variables.scope.php
2) Make sure you always quote string constants, even when used as
array indexes.
---
Geir Pedersen http://www.activio.com/
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php