How can the use of outdated mysql_* functions in PHP scripts impact the security and performance of a website?

Using outdated mysql_* functions in PHP scripts can impact the security of a website by making it vulnerable to SQL injection attacks. Additionally, these functions have been deprecated since PHP 5.5 and removed in PHP 7, which can lead to compatibility issues and poor performance. To address this, it is recommended to switch to mysqli or PDO for database operations.

// Connect to MySQL using mysqli
$mysqli = new mysqli("localhost", "username", "password", "database");

// Check connection
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Perform a query using prepared statements
$stmt = $mysqli->prepare("SELECT * FROM users WHERE username = ?");
$stmt->bind_param("s", $username);
$username = "john_doe";
$stmt->execute();
$result = $stmt->get_result();

// Fetch results
while ($row = $result->fetch_assoc()) {
    // Process data
}

// Close connection
$stmt->close();
$mysqli->close();