RE: [PHP] Re: simple, but missing something?

From: Date: Fri, 26 Mar 2004 22:11:38 +0000
Subject: RE: [PHP] Re: simple, but missing something?
Groups: php.general 
Request: Send a blank email to php-general+get-181591@lists.php.net to get a copy of this message
Geir Pedersen - Activio AS <mailto:geirp@activio.com> on Friday, March 26, 2004 2:05 PM said: > 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 an alternative to that would be to use constants. define("CFG_HOSTNAME", "www.server.com"); define("CFG_USERNAME", "username"); define("CFG_PASSWORD", "password"); define("CFG_BUGEMAIL", "admin@server.com"); function database_connection() { @mysql_connect(CFG_HOSTNAME, CFG_USERNAME, CFG_PASSWORD); @mysql_select_database(CFG_DATABASE); } hth, chris.

« previous php.general (#181591) next »