Welcome Guest, Not a member yet? Register   Sign In
External DB - error from __construct
#1

Hi!

I need to connect my app to external database, but when I chage parameters I getting error from __construct function:

Code:
Unable to connect to database server using the specified settings.
Filename: core/MY_Controller.php

Line Number: 8

This is fragment of this file:
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
MY_Controller extends CI_Controller {

 protected 
$UserData;

 public function 
__construct() {
 
parent::__construct();        // line 8

 
$UserData $this->ion_auth->user()->row();

 } 

When I delete the entire function, I get the same error but with another file.
Why? Maybe I forgot something?
Reply
#2

You definitely shouldn't remove the parent::__construct() from your constructor, as this would break things. I'm guessing that the reason this error is coming up at this particular point is because you have 'database' listed in $autoload['libraries'] in your autoload config. The location of the error isn't the important part, anyway, it's the error message itself:

Quote:Unable to connect to database server using the specified settings.

The specified settings would be whatever default settings you have configured for your database.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB