Fatal error: Call to undefined function mysql_connect()

mysql, php

Solution

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.

Problem

I have set up PHP, MySQL, and Apache. `localhost()` for PHP and it is working well. But after I downloaded MySQL, it reports: Fatal error: Call to undefined function mysql_connect() How can I fix this?

Original source

Related problems