2015-11-25 27 views
0

我在CodeIgniter中开发了一个php应用程序。我想在我的托管网站hostinger上测试我的应用程序,所以我已经上传了所有文件并配置了连接到数据库的脚本。但是我收到了以下消息:无法使用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 */ 

我在做什么错?

UPDATE笨配置文件

$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

可能重复的[CodeIgniter:无法连接到您的数据库服务器使用提供的设置错误信息](http://stackoverflow.com/questions/7254049/codeigniter-unable-to-connect-到你的数据库服务器使用提供settin) – Alex

+0

谢谢亚历克斯,但我刚刚阅读这个问题,用户已经使用<?而不是<?php,这不是我的情况。 – Dillinger

+0

http://stackoverflow.com/questions/1808365/difference-between-php-and – Alex

回答

-1

我已经改变了这一行:

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

到:

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

,现在看来工作,如果有人知道如何也许可以帮助我和其他明白为什么。感谢大家的帮助。有一个美好的一天:)

0

此错误是非常广泛:

  • 检查主机名。它是本地主机吗?请尝试127.0.0.1而不是
  • 是否是mysql extern(其他ip不是web服务器)?将web服务器ip添加到mysql db的访问列表中
  • 您连接到端口3306吗?可能您的托管合作伙伴使用的是另一个端口,而不是默认端口3306
  • 您的凭据是否正确?
  • 是否有足够的权限?
相关问题