连接到任何数据库时出现CodeIgniter错误 [英] CodeIgniter error when connecting to any database
本文介绍了连接到任何数据库时出现CodeIgniter错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚从他们的网站(版本3.0.3)下载了一个CI的新副本,只是配置数据库并加载它,但我有错误。
I just downloaded a fresh copy of CI from their site(version 3.0.3) and simply configured database and loaded it, but i am having error.
是我在config.php中的数据库配置
Below is my database configuration in config.php
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'shortagesdb',
'dbdriver' => 'mysql',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,//(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
);
我在我的控制器,即简单地加载数据库
and here is what i am doing in my controller i-e simply loading database
public function index()
{
$this->load->database();
$this->load->view('welcome_message');
}
这里没有什么好处,
Nothing fancy here and i am getting this exception no matter what
PHP Fatal error: Call to undefined function mysql_connect() in D:\Projects\ims\system\database\drivers\mysql\mysql_driver.php on line 136
任何帮助将非常感谢
推荐答案
CI 3不支持MySQL
尝试此
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root', # check username
'password' => '', # check password
'database' => 'shortagesdb', # check DB name is correct
'dbdriver' => 'mysqli', # remove mysql
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'), # remove TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
这篇关于连接到任何数据库时出现CodeIgniter错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文