0

I've made an application in php that is developed in CodeIgniter. I want test my application on my hosting website hostinger, so I've uploaded all files and configure the script for connect to the database. But I got this message:

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

In my Hostinger account information I can see:

host: http://xxx.xx.xx
database host: xxx.xxx.xxx
database name: xxx
database username: xxx
database password: ******

This is my configuration file:

<?php
class SystemConfiguration {
    // General Settings
    public static $base_url    = 'http://primodebug.esy.es/Calendario/';

    // Database Settings
    public static $db_host     = 'xxx';
    public static $db_name     = 'xxx';
    public static $db_username = 'xxx';
    public static $db_password = '*****';

    // Google Calendar API Settings
    public static $google_sync_feature  = FALSE; // Enter TRUE or FALSE;
    public static $google_product_name  = '';
    public static $google_client_id     = '';
    public static $google_client_secret = '';
    public static $google_api_key       = '';
}

/* End of file configuration.php */
/* Location: ./configuration.php */

What am I doing wrong?

UPDATE CodeIgniter Config file

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

require_once dirname(dirname(dirname(__FILE__))) . '/configuration.php';

$db['default']['hostname'] = SystemConfiguration::$db_host;     
$db['default']['username'] = SystemConfiguration::$db_username; 
$db['default']['password'] = SystemConfiguration::$db_password; 
$db['default']['database'] = SystemConfiguration::$db_name;     
$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;


/* End of file database.php */
/* Location: ./application/config/database.php */
yAnTar
  • 4,269
  • 9
  • 47
  • 73
Dillinger
  • 1,823
  • 4
  • 33
  • 78

2 Answers2

0

This error is very broad:

  • Check the host name. Is it localhost? Try 127.0.0.1 instead
  • Is mysql extern (other ip than the web server)? Add the web server ip to the access list of the mysql db
  • Do you connect to port 3306? Possibly your hosting partner uses another port than the default 3306
  • Are your credentials correct?
  • Has the user enough permissions?
schellingerht
  • 5,726
  • 2
  • 28
  • 56
-1

I've changed this line:

$db['default']['db_debug'] = TRUE;

to:

$db['default']['db_debug'] = FALSE;

and now seems working, if someone know how maybe could help me and other to understand why. Thanks to everyone for the help. Have a good day :)

Dillinger
  • 1,823
  • 4
  • 33
  • 78