How to solve "Fatal error: Class 'MySQLi' not found"?

I am doing a tutorial and am getting this error:

Fatal error: Class 'MySQLi' not found (LONG URL) on line 8

The code on line 8 is:

$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name);

I saw online someone said to see if it was turned on in my phpinfo(), but there wasn't anything listed in there under for "mysqli".

Also, I am running PHP version 5.2.5


Solution 1:

Sounds like you just need to install MySQLi.

If you think you've done that and still have a problem, please post your operating system and anything else that might help diagnose it further.

Solution 2:

You can check if the mysqli libraries are present by executing this code:

if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
    echo 'We don\'t have mysqli!!!';
} else {
    echo 'Phew we have it!';
}

Solution 3:

If you are on Ubuntu, run:

 sudo apt-get install php-mysqlnd