Home > Database > Mysql Tutorial > Why Do I Get a 'Call to undefined function mysql_connect()' Error in PHP?

Why Do I Get a 'Call to undefined function mysql_connect()' Error in PHP?

Barbara Streisand
Release: 2024-12-01 06:56:12
Original
973 people have browsed it

Why Do I Get a

Undefined Function mysql_connect() Error in PHP

Problem Statement:

Developers may encounter the "Fatal error: Call to undefined function mysql_connect()" when attempting to use the deprecated mysql_* functions in PHP. The error persists even after installing the appropriate package and restarting the necessary services.

Solution:

In PHP 7 and above, the mysql_* functions have been replaced by the PDO or mysqli_* functions. Developers are recommended to update their code accordingly. However, if it is not immediately feasible, a workaround exists.

Workaround:

For a temporary solution, developers can create the fix_mysql.inc.php file, which recreates the old mysql_* functions using the mysqli_*() functions. This file should be included at the beginning of the PHP scripts using the mysql_* functions.

The above is the detailed content of Why Do I Get a 'Call to undefined function mysql_connect()' Error in PHP?. 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