Welcome Guest, Not a member yet? Register   Sign In
Connect to mysql db on live server
#1

[eluser]morgs[/eluser]
Hi Everyone,

I'm trying to connect to a mysql db.
1. My CMS connects to different databases on remote servers depending on which website a user is editing. My CMS itself has a database which I connect to using and all works well:
Code:
$this->coredb = $this->load->database( 'default', TRUE );


But then I try to make another/different connection in a view like so:

Code:
$db[ 'dbdriver' ] = 'mysql';
$db[ 'dbprefix' ] = '';
$db[ 'pconnect' ] = TRUE;
$db[ 'db_debug' ] = TRUE;
$db[ 'hostname' ] = 'hostname.com:3307';
$db[ 'username' ] = 'username';
$db[ 'password' ] = 'password';
$db[ 'database' ] = 'database';

$websitedb = $this->load->database( $db, TRUE );

2. The above connection works on my local PC connecting to an external database server (not localhost!). But when I deploy to the live server, Codeigniter says it "cannot connect to the database". The database connection settings/string are correct. Another website can connect to the same database that Codeigniter is failing to connect to...

So is it some Codeigniter setting/issue or what's going on?
I even tried to use the standard mysql:
Code:
$conn = mysql_connect( $db->server, $db->user, $db->pass );

This fails as well, but from a different website which uses just standard php (and not Codeigniter framework) the connection is successful and I can query the database endlessly.

Any help please?

Morgs




Theme © iAndrew 2016 - Forum software by © MyBB