Home > Backend Development > PHP Tutorial > How to Fix 'Fatal Error: Call to Undefined Function mysqli_connect()'?

How to Fix 'Fatal Error: Call to Undefined Function mysqli_connect()'?

Mary-Kate Olsen
Release: 2024-12-15 20:51:14
Original
1002 people have browsed it

How to Fix

Fixing "Fatal Error: Call to Undefined Function mysqli_connect()"

You're encountering the "Fatal error: Call to undefined function mysqli_connect()" error when trying to access a database on a new server. Despite copying the relevant PHP and SQL files from a previous site where the code functioned correctly, you're facing this issue on the new server.

This error typically occurs when the MySQLi PHP extension is not installed or enabled on the new server. To resolve the problem:

Run the following command on the new server:

$ sudo apt install php-mysqli
Copy after login

This will install the necessary MySQLi PHP extension, enabling your application to access the MySQL database.

It's important to note that you may need to restart your web server after installing the extension for the changes to take effect.

The above is the detailed content of How to Fix 'Fatal Error: Call to Undefined Function mysqli_connect()'?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template