如何使用PDO修复“不支持的操作数类型”

时间:2019-07-26 14:54:41

标签: php mysql pdo

使用PDO时出现“致命错误:未捕获错误:错误的不受支持的操作数类型”。找不到解决方案。这是我的代码,我认为我的提取中有一些关于数组和行的内容,但是我不明白!

// define how many results you want per page
$results_per_page = 10;
// find out the number of results sto in database
$result = $bdd->query('SELECT * FROM threads');
$number_of_results = $result->fetch();
// determine number of total pages available
$number_of_pages = ceil($number_of_results/$results_per_page);
// determine which page number visitor is currently on
if (!isset($_GET['page'])) {
  $page = 1;
} else {
  $page = $_GET['page'];
}
// determine the sql LIMIT starting number for the results on the displaying page
$this_page_first_result = ($page-1)*$results_per_page;
// retrieve selected results from database and display them on page
$result = $bdd->prepare('SELECT * FROM threads LIMIT ?,?');
$result->execute(array($this_page_first_result,$results_per_page));
while($row = $result->fetch()) {?>red
  <tr>
       <td><a href="viewthread.php?id=<?php echo $row['id']; ?>"><?php echo $row['topic']; ?></a></td>
       <td><?php echo $row['autor']; ?></td>
       <td><?php echo $row['moment']; ?></td>
   </tr>
<?php
}
for ($page=1;$page<=$number_of_pages;$page++) {
  echo '    <a href="index.php?page=' . $page . '">' . $page . '</a>';
}

}

0 个答案:

没有答案