Re: simple, but missing something?

From: Date: Fri, 26 Mar 2004 22:07:12 +0000
Subject: Re: simple, but missing something?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-181588@lists.php.net to get a copy of this message
Jay Blanchard wrote:
[snip] $cfg['hostname'] = "www.server.com"; // Server domain or ip address
$cfg['username'] = "username";        // Database user name
$cfg['password'] = "password";        // Database password
$cfg['bugemail'] = "admin@server.com"; The do something like this: function database_connection() { @mysql_connect($cfg[hostname],$cfg[username],$cfg[password]); @mysql_select_database($cfg[database]); } [/snip] Why are you not using the single quoted array names? i.e. @mysql_connect($cfg['hostname'],$cfg['username'],$cfg['password']); Have you echo'd each out afterwords to see if they are right? Use mysql_error() to return connection errors so that you know what they are. Yeah I have tried single quoted array names, double-quoted variable names, and the output of the print_r($cfg) displays the variables are present and when I do a mysql_error() and mysql_errno() I get could not connect to database, 1046 errors.


« previous php.general (#181588) next »