我的论坛系统存在问题

时间:2018-01-23 12:01:12

标签: php mysqli

每当我刷新它再次重播重播时,我在论坛重播系统中尝试时出错了

        function replay_function ($conn){
    if (isset($_POST['replay-post'])) {
      if (empty($_POST['reply-content'])) {
        echo "you left put some fileds";
      }
      $message = mysqli_real_escape_string($conn,$_POST['reply-content']);
      $user_id = $_SESSION['id'];
      $topic_id = mysqli_real_escape_string($conn,$_GET['id']);
      $sql = "INSERT INTO replay_forum(replay,replay_date,replay_by,topic_replayed)
      VALUES('$message',NOW(),'$user_id','$topic_id')";
      $result = mysqli_query($conn,$sql);
      if(!$result)
      {
          //something went wrong, display the error
          echo 'something went wrong please try again later';
      }else {
        header('Location: ' .BASE_URL. '/topic?id='.$_GET["id"].' ');
        echo "<script>alert('your Replay Have been Saved successfully please refrech your page to see the changes')
        </script>";
    exit();
      }
    }
    }
and thisis the code am using to display 

  echo '<table border="1">
              <tr>
                <th>Category</th>
                <th>Last topic</th>
              </tr>';

        while($row = mysqli_fetch_assoc($result))
        {
          $cat_id = $row['cat_id'];
            echo '<tr>';
                echo '<td class="leftpart">';
                    echo '<h3><a href="category.php?id='.$row['cat_id'].'">' . $row['cat_name'] . '</a></h3>
                    <p class="p">' . $row['cat_description'];
                echo '</p></td>';
                echo '<td class="rightpart">';
                            $topicsql = "SELECT topic_id,topic_subject,topic_date FROM topics WHERE
                            topic_cat = '$cat_id'  ORDER BY topic_date DESC LIMIT 0, 1
                           ";
                           $topicresult = mysqli_query($conn,$topicsql);
                           if(!$topicresult)
                          {
                              echo 'nothing here yet';
                          }else {
                            if ($topicrow = mysqli_fetch_assoc($topicresult)) {
                              echo '<a href="../forum/topic?id='.$topicrow['topic_id'].' ">
                              '.$topicrow['topic_subject'].'</a> ';
                            }
                          }
                echo '</td>';
            echo '</tr>';
          }
          echo "</table>";
        }
      }

我收到此错误

警告:无法修改标头信息 - 已在C:\ xampp \ htdocs \ new \ forum \ inc \ functions中发送的标头(输出从C:\ xampp \ htdocs \ new \ forum \ topic.php:64开始)第37行的.php

我该如何解决这个问题

1 个答案:

答案 0 :(得分:0)

将以下代码放在脚本的顶部。 我的意思是当php脚本启动时,写成这样:

<?php
 ob_start();
 // rest of the code goes here..

希望有所帮助