setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $result = $conn->prepare($sql); try { $result->execute(); $rows = $result->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { echo "Error : " . $e->getMessage(); } $title = $rows['title']; $type = $rows['title']; ?>