我的404.php页面问题,无法正常工作

时间:2018-08-15 18:27:16

标签: php url-redirection

嗨,当我的网站应重定向到我的404.php时,出现此错误。 警告:无法修改标头信息-第38行的C:\ xampp \ htdocs \ post.php中已经发送过的标头(输出始于C:\ xampp \ htdocs \ includes \ header.php:8)

<?php include 'includes/header.php'; ?>
<?php
     if (!isset($_GET['id']) || $_GET['id'] == NULL) {
          header("location: 404.php");
     } else {
       $id = $_GET['id'];
     }
?>
 <div class="content">
   <div class="main-content">
     <div class="post">
<?php
$query = "select * from tbl_post where id=$id";
$post = $db->select($query);
if ($post) {
while ($result = $post->fetch_assoc()) {
?>
              <h2><?php echo $result['title']; ?></h2>
              <h4><?php echo $fm->formatDate($result['date']); ?>, توسط <a href="#"><?php echo $result['author']; ?></a></h4>
              <img src="admin/upload/<?php echo $result['image']; ?>" alt="Post image"/>
<?php echo $result['body']; ?>

               <div class="relatedpost">
                 <h2>مطالب مرتبط</h2>
<?php
                    $catid = $result['cat'];
                    $queryrelated = "select * from tbl_post where cat='$catid' limit 3";
                    $relatedpost = $db->select($queryrelated);
                    if ($relatedpost) {
                    while ($rresult = $relatedpost->fetch_assoc()) {
?>

                  <a href="post.php?id=<?php echo $rresult['id']; ?>">
                    <img src="admin/upload/<?php echo $rresult['image']; ?>" alt="Post Image"/>
                  </a>
<?php } } else { echo "هیچ مطلب مرتبطی یافت نشد .متاسفیم !!"; } ?>
               </div>
<?php } } else { header("location:404.php");} ?>
     </div>
   </div>
 </div>
 <?php include 'includes/sidebar.php'; ?>
<?php include 'includes/footer.php'; ?>

上面是我的post.php

0 个答案:

没有答案