Fatal error: Call to undefined function mysql_connect()

You upgraded to PHP 7, and now mysql_connect is deprecated. Check yours with:

php -version

Change it to mysqli_connect as in:

$host = "127.0.0.1";
$username = "root";
$pass = "foobar";
$con = mysqli_connect($host, $username, $pass, "your_database");

If you’re upgrading legacy PHP, now you’re faced with the task of upgrading all your mysql_* functions with mysqli_* functions.

Leave a Comment