Codeigniter error: Call to undefined function mysql_pconnect()

前端 未结 4 566
时光说笑
时光说笑 2020-12-14 16:49

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          


        
相关标签:
4条回答
  • 2020-12-14 17:09

    Deprecated features in PHP 5.5.x:

    The original MySQL extension is now deprecated, and will generate E_DEPRECATED errors when connecting to a database. Instead, use the MySQLi or PDO_MySQL extensions.

    You're using the deprecated 'mysql' dbdriver. Locate the config/database.php file and change dbdriver to use 'mysqli' :

    $db['default']['dbdriver'] = 'mysqli'; 
    
    0 讨论(0)
  • 2020-12-14 17:17

    go to application/config/database.php
    and just change mysql to mysqli

    like this was before:

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

    this was after solution:

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

    i just change mysql to mysqli. that's it

    my error was

    Fatal error: Uncaught Error: Call to undefined function mysql_pconnect() in E:\manish_data\software\xampp\htdocs\ci2\system\database\drivers\mysql\mysql_driver.php:92 Stack trace: #0 E:\manish_data\software\xampp\htdocs\ci2\system\database\DB_driver.php(116): CI_DB_mysql_driver->db_pconnect() #1 E:\manish_data\software\xampp\htdocs\ci2\system\database\DB.php(149): CI_DB_driver->initialize() #2 E:\manish_data\software\xampp\htdocs\ci2\system\core\Loader.php(347): DB(Array, NULL) #3 E:\manish_data\software\xampp\htdocs\ci2\application\models\usermodel.php(20): CI_Loader->database() #4 E:\manish_data\software\xampp\htdocs\ci2\application\controllers\users.php(15): UserModel->getUsers() #5 E:\manish_data\software\xampp\htdocs\ci2\system\core\CodeIgniter.php(360): Users->index() #6 E:\manish_data\software\xampp\htdocs\ci2\index.php(202): require_once('E:\manish_data\...') #7 {main} thrown in E:\manish_data\software\xampp\htdocs\ci2\system\database\drivers\mysql\mysql_driver.php on line 92

    0 讨论(0)
  • 2020-12-14 17:25

    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!

    0 讨论(0)
  • 2020-12-14 17:26

    If this error happened when you're hosting the website, make sure to set the correct PHP Version (the one your CI use).

    0 讨论(0)
提交回复
热议问题