Home > Article > Backend Development > Why am I Getting the \"Call to Undefined Function mysql_connect()\" Error in PHP7?
Undefined Function mysql_connect()
Encountering the "Call to undefined function mysql_connect()" error suggests a potential issue with your PHP configuration.
Issue:
After installing the necessary PHP module (php5-mysql), you are still confronted with the error during runtime.
Explanation:
In PHP7, the previously deprecated mysql_ functions have been completely removed. This means that if you are using PHP7, you must update your code to utilize the PDO-functions or mysqli_ functions instead.
Workaround:
If updating your code is not feasible, you can implement a temporary workaround. Create a PHP include file, fix_mysql.inc.php, which remaps the old mysql_ functions to mysqli_() functions.
By using this workaround, you can continue to use your existing code without encountering the undefined function error. However, it is recommended to modify your code to use the appropriate PHP functions for compatibility with future versions.
The above is the detailed content of Why am I Getting the \"Call to Undefined Function mysql_connect()\" Error in PHP7?. For more information, please follow other related articles on the PHP Chinese website!