Undefined Function 'mysql_connect()' in PHP
You've configured PHP, MySQL, and Apache, and localhost() functions correctly in PHP. However, after installing MySQL, you encounter the error:
Fatal error: Call to undefined function mysql_connect()
This issue arises because you have upgraded to PHP 7, where the mysql_connect function is deprecated. To resolve it:
$host = "127.0.0.1"; $username = "root"; $pass = "foobar"; $con = mysqli_connect($host, $username, $pass, "your_database");
If you're migrating legacy PHP code, you'll need to convert all your mysql_* functions to mysqli_* equivalents.
The above is the detailed content of Why is `mysql_connect()` Deprecated in PHP 7 and How Do I Fix It?. For more information, please follow other related articles on the PHP Chinese website!