exec($sql); } catch (PDOException $e) { // Ignore errors, like column already exists } } } catch (PDOException $e) { // In a real app, you'd log this error. // For now, we'll just output a generic error. die("Database migration failed: " . $e->getMessage()); } } // Run migrations run_migrations(); // Fetch tasks $tasks = []; try { $pdo = db(); $stmt = $pdo->prepare("SELECT * FROM tasks WHERE user_id = ? ORDER BY created_at DESC"); $stmt->execute([$_SESSION['user_id']]); $tasks = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { echo '