When executing the PHP file on the local development server you may face an issue saying
GET /database.php – Uncaught Error: Class “mysqli” not found in …\server\database.php:9
Stack trace:
#0 {main}
thrown in …\server\database.php on line 9
Let’s have a look at how to resolve this fatal error when executing the PHP file on the local server by executing the below commanding the terminal window:
php -S 127.0.0.1:8080
The above command will run and start the development server to serve your local PHP file.
Why Fatal Error?
when using the MySQLi in the PHP file you may face this issue which is not properly configured to use the methods of PHP library with updated versions.
Solutions
Let’s have a look at possible solutions:
Method 1) You need to install MySQLi on your system.
Method 2) You can add an error handler inside the PHP file, to check if MySQLi is available or not:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'Why you no have mysqli!!!';
} else {
echo 'Day is saved!';
}
Hope this helped! 🙂
Leave a Reply