Welcome Guest, Not a member yet? Register   Sign In
Newbie trying to connect to a remote database (works on localhost)
#1

[eluser]Chuck91[/eluser]
Hello,

I have been working with CodeIgniter now for about a month and have gotten reasonably familiar with it.

However, all this while, I have been working with a local database (with hostname as localhost in database.php)

I am now trying to get CI to run with a remote database and its failing silently with no error in the logs (although log threshold is set to 4 in config.php)

$config['log_threshold'] = 4;

Local machine - Windows Vista laptop
Remote machine - Linux Ubuntu desktop

I have tested that
1) I can connect to the remote database using PHPMyAdmin
2) The same CI files work if installed directly on the remote machine
3) CI works on the local machine

I have even tried using a try-catch block for loading the database but it fails silently (no output on the page or in the logs).

Is there a way for me to find out what the error is?

Any help would be greatly appreciated.

Thanks.
Sudip
#2

[eluser]Krzemo[/eluser]
Most likely DB user is not allowing remote hosts...
#3

[eluser]Chuck91[/eluser]
Would PHPMyAdmin still work remotely in that case?
#4

[eluser]jedd[/eluser]
Dumb questions, but have to be asked:
Do you connect using phpmyadmin using the same credentials as your application is using to connect to the database?
Do you use the same hostname or IP address format in both places?
#5

[eluser]Krzemo[/eluser]
Its not about type of client. Its abt user configuration in database.
#6

[eluser]bretticus[/eluser]
[quote author="Chuck91" date="1249515554"]Would PHPMyAdmin still work remotely in that case?[/quote]

Yes, phpMyAdmin is running as the web server on the Linux host and when it connects to MySQL, it connects as localhost.

Instructions
#7

[eluser]Chuck91[/eluser]
Folks,

Thanks to all those who responded.

I am able to connect using SQLYog. I am using the exact SAME hostname, username, password and database for both SQLYog and CodeIgniter (database.php file).

If I just use PHP code everything works fine. However, as soon as I add the line

$this->load->database();

in the Controller constructor, it fails silently with no output and with no error logs when I try to access it.

The logs show the following:

DEBUG - 2009-08-05 22:44:19 --> Config Class Initialized
DEBUG - 2009-08-05 22:44:19 --> Hooks Class Initialized
DEBUG - 2009-08-05 22:44:19 --> URI Class Initialized
DEBUG - 2009-08-05 22:44:19 --> Router Class Initialized
DEBUG - 2009-08-05 22:44:19 --> Output Class Initialized
DEBUG - 2009-08-05 22:44:19 --> Input Class Initialized
DEBUG - 2009-08-05 22:44:19 --> Global POST and COOKIE data sanitized
DEBUG - 2009-08-05 22:44:19 --> Language Class Initialized
DEBUG - 2009-08-05 22:44:19 --> Loader Class Initialized
DEBUG - 2009-08-05 22:44:19 --> Controller Class Initialized
DEBUG - 2009-08-05 22:44:19 --> Database Driver Class Initialized

Once again, thanks in advance for any help you provide.

Sudip
#8

[eluser]thephpx[/eluser]
Check your autoload.php in config folder and see if database is set to auto-load. If its set to auto-load then comment the "$this->load->database();" line in controller and try now Smile

Hope it will solve it. Don't know why it happens but it happened to me quite often :p
#9

[eluser]Chuck91[/eluser]
Hello "thephpx"

Thanks for your response.

No, database is not set to auto-load.
#10

[eluser]Unknown[/eluser]
Ever get an answer to this? I'm seeing similar behavior (or, rather, non-behavior).

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB