Home >Backend Development >PHP Tutorial >Why Isn't My PHP Code Finding the MySQLi Class?

Why Isn't My PHP Code Finding the MySQLi Class?

Susan Sarandon
Susan SarandonOriginal
2024-12-12 19:25:14845browse

Why Isn't My PHP Code Finding the MySQLi Class?

How to Resolve "Class 'MySQLi' Not Found" Error in PHP?

When attempting to execute a PHP script, you may encounter the following error:

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

This error typically arises when you attempt to establish a connection to a MySQL database using the MySQLi extension.

Cause:

The error occurs because the MySQLi extension is not enabled or installed on your system.

Solution:

To resolve this error, follow these steps:

  1. Install MySQLi: Install the MySQLi extension for your specific PHP version. Refer to the official PHP documentation for installation instructions.
  2. Enable MySQLi: After installation, enable the MySQLi extension by adding the following line to your php.ini file:
extension=mysqli.so
  1. Restart PHP: Restart your PHP server to apply the changes.

Note for PHP 5.2.5:

PHP 5.2.5 does not support the MySQLi extension natively. You will need to install the PECL MySQLi extension specifically for PHP 5.2.5. Refer to the PECL documentation for installation instructions.

The above is the detailed content of Why Isn't My PHP Code Finding the MySQLi Class?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn