setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); } catch (PDOException $e) { // In a production environment, log the error and show a generic message error_log("Database connection failed: " . $e->getMessage()); die("A problem occurred with the database connection. Please try again later."); } ?>