What are common reasons for the "Call to undefined function mysql_connect()" error in PHP scripts running on Linux?

The "Call to undefined function mysql_connect()" error in PHP scripts running on Linux typically occurs when the MySQL extension is not enabled or installed on the server. To solve this issue, you can switch to using the MySQLi or PDO extension for connecting to MySQL databases, as the original MySQL extension is deprecated in PHP 7 and removed in PHP 7.0.0.

// Connect to MySQL database using MySQLi extension
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";