Codeigniter 3.0.3 数据库配置
Codeigniter 3.0.3 Database configration
我是 codeigniter 3.0 的新手。我正在将我的项目上传到我的服务器上。但我面临一些困扰我的错误。但它在本地运行良好。我用谷歌搜索但没有找到我的答案。我认为存在一些数据库配置问题。
这是我的database.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'http://selectomobile.com/freber',
'username' => 'my username',
'password' => 'mypassword',
'database' => 'mydatabasename',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
有些错误让我很恼火。
1.
遇到了一个PHP错误
严重性:警告
消息:mysqli::real_connect():php_network_getaddresses:getaddrinfo 失败:名称或服务未知
文件名:mysqli/mysqli_driver.php
行号:161
回溯:
文件:/home/selectom/public_html/freber/index.php
线路:292
函数:require_once
2.
遇到了一个PHP错误
严重性:警告
消息:mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known
文件名:mysqli/mysqli_driver.php
行号:161
回溯:
文件:/home/selectom/public_html/freber/index.php
线路:292
函数:require_once
3.
遇到了一个PHP错误
严重性:警告
消息:无法修改 header 信息 - headers 已经发送(输出开始于 /home/selectom/public_html/freber/system/core/Exceptions.php:272)
文件名:core/Common.php
行号:568
回溯:
文件:/home/selectom/public_html/freber/index.php
线路:292
函数:require_once
4.
发生数据库错误
无法使用提供的设置连接到您的数据库服务器。
文件名:core/CodeIgniter.php
行号:500
您的代码有误
您的代码
$db['default'] = array(
'dsn' => '',
'hostname' => 'http://selectomobile.com/freber', # Wrong
'username' => 'my username',
'password' => 'mypassword',
'database' => 'mydatabasename',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE, # don't change this
'db_debug' => (ENVIRONMENT !== 'production'), # Wrong
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE # There is no such config
);
我的 (Database Configuration Codeigniter)
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost', # this should be localhost
'username' => 'root', # username which creates from DB wizard
'password' => '', # password which creates from DB wizard
'database' => 'database_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE, # Changed
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array()
);
要换环境
转到根目录中的 index.php
。 (如果CI3第56行)
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
可用环境
- 发展
- 测试
- 生产
我是 codeigniter 3.0 的新手。我正在将我的项目上传到我的服务器上。但我面临一些困扰我的错误。但它在本地运行良好。我用谷歌搜索但没有找到我的答案。我认为存在一些数据库配置问题。
这是我的database.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'http://selectomobile.com/freber',
'username' => 'my username',
'password' => 'mypassword',
'database' => 'mydatabasename',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
有些错误让我很恼火。
1.
遇到了一个PHP错误 严重性:警告 消息:mysqli::real_connect():php_network_getaddresses:getaddrinfo 失败:名称或服务未知 文件名:mysqli/mysqli_driver.php 行号:161 回溯: 文件:/home/selectom/public_html/freber/index.php 线路:292 函数:require_once
2.
遇到了一个PHP错误 严重性:警告 消息:mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known 文件名:mysqli/mysqli_driver.php 行号:161 回溯: 文件:/home/selectom/public_html/freber/index.php 线路:292 函数:require_once
3.
遇到了一个PHP错误 严重性:警告 消息:无法修改 header 信息 - headers 已经发送(输出开始于 /home/selectom/public_html/freber/system/core/Exceptions.php:272) 文件名:core/Common.php 行号:568 回溯: 文件:/home/selectom/public_html/freber/index.php 线路:292 函数:require_once
4.
发生数据库错误 无法使用提供的设置连接到您的数据库服务器。 文件名:core/CodeIgniter.php 行号:500
您的代码有误
您的代码
$db['default'] = array(
'dsn' => '',
'hostname' => 'http://selectomobile.com/freber', # Wrong
'username' => 'my username',
'password' => 'mypassword',
'database' => 'mydatabasename',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE, # don't change this
'db_debug' => (ENVIRONMENT !== 'production'), # Wrong
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE # There is no such config
);
我的 (Database Configuration Codeigniter)
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost', # this should be localhost
'username' => 'root', # username which creates from DB wizard
'password' => '', # password which creates from DB wizard
'database' => 'database_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE, # Changed
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array()
);
要换环境
转到根目录中的 index.php
。 (如果CI3第56行)
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
可用环境
- 发展
- 测试
- 生产