Не удается получить идентификатор строки с помощью pdo

Я не могу взять строку db с помощью PDO. В настоящее время я использую fetch(PDO::FETCH_ASSOC) но мой результат показывает пробел.

Это мой код:

  <?php ini_set('display_errors', 1); //create_cat.php include 'dbfunctions.php'; include 'forum_header.php'; $db = getConnection(); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $id = $_GET['id']; $sql = "SELECT topicid, topicsubject FROM topics WHERE topics.topicid = :id "; $result = $db->prepare($sql); $result->bindParam(":id", $id, PDO::PARAM_INT); $result->execute(); $numrows = $result->fetchColumn(); if(!$result) { echo 'The topic could not be displayed, please try again later.'; } else { while($topicrow = $result->fetchAll(PDO::FETCH_ASSOC)) { echo "hello"; //display post data echo '<table class="topic" border="1">'; echo '<tr>'; echo '<th colspan="2">' . $topicrow['topicsubject'] . '</th>'; echo '</tr>'; //fetch the posts from the database $posts_sql = "SELECT posts.topicid, posts.postcontent, posts.postdate, posts.postby, users.userID FROM posts LEFT JOIN users ON posts.postby = users.userID WHERE posts.topicid = :id "; $posts_result = $db->prepare($posts_sql); $posts_result->bindParam(":id", $id, PDO::PARAM_INT); $posts_result->execute(); $posts_numrows = $posts_result->fetchColumn(); if(!$posts_result) { echo '<tr><td>The posts could not be displayed, please try again later.</tr></td></table>'; } else { while($posts_row = $posts_result->fetch(PDO::FETCH_ASSOC)) { echo '<tr class="topic-post"> <td class="user-post">' . $posts_row['userID'] . '<br/>' . date('dmY H:i', strtotime($posts_row['postdate'])) . '</td> <td class="post-content">' . htmlentities(stripslashes($posts_row['postcontent'])) . '</td> </tr>'; } } if(!$_SESSION['CurrentUser']) { echo '<tr><td colspan=2>You must be <a href="signin.php">signed in</a> to reply. You can also <a href="signup.php">sign up</a> for an account.'; } else { //show reply box echo '<tr><td colspan="2"><h2>Reply:</h2><br /> <form method="post" action="forum_reply.php?id=' . $row['topicid'] . '"> <textarea name="reply-content"></textarea><br /><br /> <input type="submit" value="Submit reply" /> </form></td></tr>'; } //finish the table echo '</table>'; } } include 'forum_footer.php'; ?> 

После цикла while я не могу получить свою строку ['topicubject'], я что-то пропустил. Могу ли я помочь мне с этим. Спасибо.

Solutions Collecting From Web of "Не удается получить идентификатор строки с помощью pdo"