Welcome Guest, Not a member yet? Register   Sign In
In CodeIgniter: changing database driver to 'mysqli' doesn't work!

Everything ran fine yesterday. Today, magically, I was victim of the infamous "white screen of death". The PHP pages kept being served blank. Being new at this, and not knowing better, I re-installed XAMPP (with which I run CodeIgniter). I had to edit my php.ini file once again, and insert all the necessary information, like the mysql.default_port, mysql.default_socket, mysql.default_host and mysql.default_user.

Having googled my problem, I found a way for me to know what was causing all of this:

A PHP Error was encountered
Severity: 8192
Message: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
Filename: config/database.php
Line Number: 80

So, I went onto my database.php in CI, and changed $db['default']['dbdriver'] = 'mysql'; to $db['default']['dbdriver'] = 'mysqli';
I come back to my php page, and the error hasn't gone away. What should I do?

Here's my whole database.php:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = ''; // Don't have a password
$db['default']['database'] = 'db';
$db['default']['dbdriver'] = 'mysqli';
$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;
$db['default']['port'] = "3306";

Thanks in advance!

blank pages usually indicate a fatal error, but you have errors suppressed so you aren't seeing them on the screen. I would check the apache error log as well as the php error log to see what's going on.

What version of CI are you using? Do you have the mysqli extension enabled in PHP (not just CI)? If you do a php_info(); do you see an entry for mysqli?

It's been a while since I've renamed my CI folder, but there's a big chance it's CodeIgniter V 2.1.4. When I check out my phpinfo() (in a separate page in the root of my CI folder - controller doesn't serve pages without an error), I see the same info in mysqli than I have in the mysql table.
" Do you have the mysqli extension enabled in PHP (not just CI)?" -> How do you check for that?
I've also checked the apache log, but don't understand it, what should I be looking for?

Thanks again

Sorry, the mysql table has 2 Active Persistent Links and 2 Active Links. The mysqli table has 0 for both.

Easy way to check for a mysqli connection. Just create a new php file and add this code to the root.


$db_conn = mysqli_connect("localhost", "user_name", "password", "database_name");

// Evaluate the connection
if (mysqli_connect_errno())
    echo mysqli_connect_error();

    echo "Successful database connection, happy coding!!!";


@InsiteFX, I ran your code and got the successful message. I can connect to my db with mysqli, right? But when I come back to my initial controller and run a function, the initial error was still there. Does this mean there's a problem with my mysqli driver?

Hi, I' am not sure what version of CI you are running but I run mysqli on CI ver 2.2.0 with HMVC and have no problems.

Try setting this:
$db['default']['pconnect'] = FALSE;

I tried it. Nothing's changed. Do you think this is a PHP problem and I need to re-install PHP 5.5.11 or do you think it's a CI problem and I should get the new version and try then?

Check these extensions in your php.ini file, they should both be like below with no ; in front of them.

Woah, they both had ; in front of them. I took them off, saved the file, restarted the XAMPP and reloaded my initial controller. No results! Still tells me I need to use mysqli because mysql's been deprecated while I have
$db['default']['dbdriver'] = 'mysqli';
in my database.php

Theme © iAndrew 2016 - Forum software by © MyBB