doukai1226 2016-04-24 11:24
浏览 253
已采纳

Codeigniter错误:调用未定义的函数mysql_pconnect()

I have updated my codeigniter version from 2.2.4 step by step to 3.0.6 and I get an error:

An uncaught Exception was encountered

Type: Error

Message: Call to undefined function mysql_pconnect()

Filename: path-to-project\system\database\drivers\mysql\mysql_driver.php

Line Number: 135

Backtrace:

File: path-to-project\application\controllers\Main.php
Line: 10
Function: __construct

File: path-to-project\index.php
Line: 315
Function: require_once

I have just replaced my index.php file and system directory with the new one and made some changes in my application according to tutorial.

and this is the Main controller:

class Main extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->model('main_model');
    }
}

What causes the problem?!

And this is the link of the tutorial.

  • 写回答

3条回答

  • dongzh1988 2016-04-24 11:35
    关注

    Thanks to Anant

    I come to a conclusion:

    I completely changed my old database.php file in config folder with the new one:

    From:

    $db['default']['hostname'] = 'localhost';
    $db['default']['username'] = '';
    $db['default']['password'] = '';
    $db['default']['database'] = '';
    $db['default']['dbdriver'] = '';
    $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;
    

    To:

    $db['default'] = array(
        'dsn'   => '',
        'hostname' => '',
        'username' => '',
        'password' => '',
        'database' => '',
        '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
    );
    

    And the error is gone!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现