What are some alternative PHP functions or methods that can be used to achieve the same result as the provided code snippets?

The issue with the provided code snippets is the use of the deprecated "mysql_" functions, which are no longer supported in newer versions of PHP. To solve this issue, we can switch to using the "mysqli_" functions or PDO (PHP Data Objects) for database operations.

// Using mysqli functions
$mysqli = new mysqli($host, $user, $password, $database);

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

$result = $mysqli->query("SELECT * FROM users");

while ($row = $result->fetch_assoc()) {
    echo $row['username'] . "<br>";
}

$mysqli->close();