In what scenarios might PHP output the error message "undefined function" even when attempting to use a commonly recognized function like mysql_connect()?

When encountering an "undefined function" error while trying to use a commonly recognized function like mysql_connect(), it is likely due to the function being deprecated or not enabled in the PHP configuration. In newer PHP versions, the MySQL extension has been removed, and functions like mysql_connect() are no longer available. To resolve this issue, you should use the MySQLi or PDO extension for connecting to a MySQL database instead.

// Using MySQLi extension to connect to a MySQL database
$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";