mysql_pconnect()出错,致命错误:未捕获错误:调用未定义函数mysql_pconnect()

I got these error in Codeigniter.

Fatal error: Uncaught Error: Call to undefined function mysql_pconnect() in

C:\xampp1\htdocs\CI\system\database\drivers\mysql\mysql_driver.php:92

Stack trace: #0

C:\xampp1\htdocs\CI\system\database\DB_driver.php(116):

CI_DB_mysql_driver->db_pconnect() #1

C:\xampp1\htdocs\CI\system\database\DB.php(149):

CI_DB_driver->initialize() #2

C:\xampp1\htdocs\CI\system\core\Loader.php(347): DB(Array, NULL) #3

C:\xampp1\htdocs\CI\application\models\usermodel.php(7):

CI_Loader->database() #4

C:\xampp1\htdocs\CI\application\controllers\userscontroller.php(9):

UserModel->getUser() #5

C:\xampp1\htdocs\CI\system\core\CodeIgniter.php(360):

UsersController->index() #6 C:\xampp1\htdocs\CI\index.php(202):

require_once('C:\xampp1\htdoc...') #7 {main} thrown in

C:\xampp1\htdocs\CI\system\database\drivers\mysql\mysql_driver.php on

line 92

Model class

class UserModel extends CI_Model

{

public function getUser()

{

$this->load->database();

$query = $this->db->query("SELECT * from user_accounts");

return $query->result();

}

}

View class

User Accounts
= $user->firstname; ?>= $user->lastname; ?>

Controller class

class UsersController extends CI_Controller

{

public function index()

{

$this->load->model('usermodel');

$data['users'] = $this->usermodel->getUser();

$this->load->view('user_list',$data);

}

}

database.php

$active_group = 'default';

$active_record = TRUE;

$db['default']['hostname'] = 'localhost';

$db['default']['username'] = 'root';

$db['default']['password'] = '';

$db['default']['database'] = 'ci_users';

$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;

解决方案

Because you're using Codeigniter, you're most likely using their Database Class and drivers so you're not using PHP's MySQL functions directly.

Therefore, all you need to do is change

$db['default']['dbdriver'] = 'mysql';

to

$db['default']['dbdriver'] = 'mysqli';

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值