Challenge 1 — Solution Task: Write the PDO connection code for a database called "blog_db" on localhost, wrapped in a try/catch that dies with a friendly message on failure. Set both ERRMODE_EXCEPTION and FETCH_ASSOC as attributes. setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); } catch (PDOException $e) { die("Sorry, we couldn't connect to the database right now. Please try again later."); } ?> Output: (No output on a successful connection — the script simply continues. If the connection failed, the friendly die() message would print instead, e.g.:) Sorry, we couldn't connect to the database right now. Please try again later. Notes: - The friendly die() message deliberately does NOT include $e->getMessage() - a raw database error can leak sensitive details (table names, server paths, sometimes even partial credentials) to anyone viewing the page, which is exactly the kind of information an attacker would find useful. - ERRMODE_EXCEPTION means any later database error (a bad query, a constraint violation) throws a PDOException too, not just a connection failure - catching problems consistently throughout the whole script, not only at the connection step. - FETCH_ASSOC set here as a default means every future fetch()/ fetchAll() call automatically returns clean associative arrays, without needing to repeat the fetch mode on every single query.