• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Mysql connect to second database

AndyB

Well-known member
#1
I have an add-on in which I'm trying to connect to a second database. Why is this PHP code not working?

PHP:
$db = Zend_Db::factory('mysqli',
	array(
	'host' => $config['db']['localhost'],
	'port' => $config['db']['3306'],
	'username' => $config['db']['XXX'],
	'password' => $config['db']['XXX'],
	'dbname' => $config['db']['XXX']
	)
);

$db->getConnection();
I get the following error:

Access denied for user ''@'localhost' (using password: NO)
 

AndyB

Well-known member
#2
The server error log shows this:

Code:
ErrorException: Undefined variable: config - library/Andy/InternalDataCheck/ControllerPublic/InternalDataCheck.php:32
Generated By: AndyB, 3 minutes ago
 

AndyB

Well-known member
#3
Got it:

PHP:
$db = Zend_Db::factory('mysqli',
	array(
	'host' => 'localhost',
	'port' => '3306',
	'username' => 'XXX',
	'password' => 'XXX',
	'dbname' => 'XXX'
	)
);

$db->getConnection();