我在CodeIgniter
开发的php中创建了一个应用程序。我想在我的托管网站hostinger上测试我的应用程序,所以我已经上传了所有文件并配置了连接数据库的脚本。但我收到了这条消息:
无法使用提供的设置连接到数据库服务器。
在我的Hostinger帐户信息中,我可以看到:
host: http://xxx.xx.xx
database host: xxx.xxx.xxx
database name: xxx
database username: xxx
database password: ******
这是我的configuration
文件:
<?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 */
我做错了什么?
更新CodeIgniter配置文件
$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 */
答案 0 :(得分:0)
此错误非常广泛:
答案 1 :(得分:-1)
我改变了这一行:
$db['default']['db_debug'] = TRUE;
为:
$db['default']['db_debug'] = FALSE;
如果有人知道怎么可能帮助我和其他人理解原因,那么现在看起来很有效。感谢大家的帮助。祝你有个美好的一天:)