CodeIgniter Forums
External DB? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: External DB? (/showthread.php?tid=29394)



External DB? - El Forum - 04-08-2010

[eluser]spaceflunk[/eluser]
Hello
Isnt it possible to connect to an external DB using codeignitor?


Thanks!


External DB? - El Forum - 04-08-2010

[eluser]danmontgomery[/eluser]
Yes...

Code:
$db['default']['hostname'] = "[address to database server]";



External DB? - El Forum - 04-08-2010

[eluser]spaceflunk[/eluser]
When i do this i get this error:


-----------------------------------------------------------------------
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /share/HDA_DATA/Qweb/system/application/controllers/pos.php:3)

Filename: codeigniter/Common.php

Line Number: 360
A Database Error Occurred

Unable to connect to your database server using the provided settings.


-----------------------------------------------------------------------

But the server isnt on a standard port, but port 3306.

$db['default']['hostname'] = "[adress]:3306";

Isnt this correct?


External DB? - El Forum - 04-08-2010

[eluser]danmontgomery[/eluser]
It is... 3306 is the default port for MySQL, what DB are you using?

I would check settings on the DB server.


External DB? - El Forum - 04-08-2010

[eluser]spaceflunk[/eluser]
It is just regular mysql on a hosted server. Dont know if there is a setting allowing external connections, do you know that?


External DB? - El Forum - 04-08-2010

[eluser]danmontgomery[/eluser]
There's not. But you don't need to add :3306 for mysql, as it's the default port (although doing so makes no difference).

Again, I would check settings on the DB server. The server may be rejecting all external connections to that port, or you may just need to add permissions for the user. Your host would be able to tell you things like this.