Problem
I’m working on a tutorial and I’m receiving the following error:
Line 8 contains the following code:
$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name);
I saw somewhere online that I should check my phpinfo() to see whether it was switched on, but there was nothing shown under “mysqli” there.
In addition, I’m using PHP 5.2.5.
Asked by Tylor
Solution #1
Sounds like you just need to install MySQLi.
If you’ve done all of that and still have an issue, please share your operating system and any other information that can help us figure out what’s wrong.
Answered by Greg
Solution #2
Execute the following code to see if the mysqli libraries are present:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'We don\'t have mysqli!!!';
} else {
echo 'Phew we have it!';
}
Answered by karim79
Solution #3
If you’re using Ubuntu, type:
sudo apt-get install php-mysqlnd
Answered by anshuman
Solution #4
You might get a similar problem if you call “new mysqli(..)” from within a namespaced class. Fatal blunder: The class ‘foobarmysqli’ was not found. The solution is to set it to the root namespace with a preceding backslash, as shown below:
<?php
$mysqli = new \MySQLi($db_server, $db_user, $db_pass, $db_name);
Answered by alexkb
Solution #5
Uncomment the extension dir directive in php.ini and specify your location in addition to uncommenting the php mysqli.dll extension:
extension_dir = "C:\software\php\dist\ext"
This was the key to making it work for me.
Answered by catawampus
Post is based on https://stackoverflow.com/questions/666811/how-to-solve-fatal-error-class-mysqli-not-found