0

I have a problem in connecting to the database in remote server. The code is /config/database.php is as follows:

$active_group = 'default';
$active_group = 'main';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'local_server';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;


$db['main']['hostname']='xxx.xx.xx.xx';
$db['main']['username']='user';
$db['main']['password'] ='pwd';
$db['main']['database'] = 'database1';
$db['main']['dbdriver'] = 'mysql';
$db['main']['dbprefix'] = '';
$db['main']['pconnect'] = TRUE;
$db['main']['db_debug'] = TRUE;
$db['main']['cache_on'] = FALSE;
$db['main']['cachedir'] = '';
$db['main']['char_set'] = 'utf8';
$db['main']['dbcollat'] = 'utf8_general_ci';
$db['main']['swap_pre'] = '';
$db['main']['autoinit'] = TRUE;
$db['main']['stricton'] = FALSE;

In /system/database/DB_driver.php. I have changed the pconnect to true var $pconnect= TRUE;

From the controller say student i try to connect the remote server database say "database1" as per the below code:

public function check_main()
    {
        $this->load->database('database1','TRUE');
    }

I get the following error:

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

Filename: C:\xampp\htdocs\student_attendance\system\database\DB_driver.php

Line Number: 124

In the remote server, % wildcard is given for "Remote Database Access Hosts"
4
  • you haven't configure your Remote Database Access Hosts correct at the remote host , fix it :) Commented Apr 19, 2014 at 9:51
  • Can u please elaborate on how to configure remote database access hosts???? @Svetlio Commented Apr 19, 2014 at 9:56
  • @Svetlio I tried by giving my IP address in Remote Database Access Hosts......I still face the same error.... Commented Apr 19, 2014 at 10:12
  • Can you connect to your database with the values given using a database manager, as MySQL workbench, YogSQL or HeidiSQL? Commented Jul 29, 2014 at 11:23

1 Answer 1

1
$active_group = 'default';

$active_group = 'main';

$active_record = TRUE;


try to change above code to

$active_group = 'default';

$active_record = TRUE;


Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.