In what ways can the use of PHP functions like mysql_query() and mysql_fetch_assoc() affect the overall performance and functionality of a PHP script?

Using functions like mysql_query() and mysql_fetch_assoc() can affect the performance and functionality of a PHP script due to their deprecated status in newer versions of PHP. It is recommended to use mysqli or PDO functions for database interactions to ensure better security and compatibility with modern PHP versions.

// Example of using mysqli functions to query a database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

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

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

// Perform a query
$sql = "SELECT id, name, email FROM users";
$result = $conn->query($sql);

// Fetch data and output
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "id: " . $row["id"]. " - Name: " . $row["name"]. " - Email: " . $row["email"]. "<br>";
    }
} else {
    echo "0 results";
}

// Close connection
$conn->close();