douke9379
2013-01-12 22:13
浏览 111
已采纳

PHP标头位置不起作用[重复]

Possible Duplicate:
Headers already sent by PHP

Here is my current script. Instead of redirecting like I would like it to, the page just refreshes to the current page. The page used to work, but stopped working recently for no reason. I'm on PHP 5.3

<?php
$page = "Edit Topic";
require('top.php');
$var = safe($_GET['id']);
$q = mysql_query("SELECT * FROM `topics` WHERE `id`='".$var."'");
$r = mysql_fetch_array($q);
$c = mysql_num_rows($q);
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$_SESSION['id']."'"));

if($c==0) {
     echo "<p>This topic does not exist.</p>";
} elseif($_SESSION['name'] != $r['poster'] && $user['rank'] == "Member") {
     echo "<p>This is not your topic.</p>";
} else {
     if(isset($_POST['enter'])) {
          $title = safe($_POST['title']);
          $post = safe($_POST['post']);

          if($post=='' || $title=='') {
               $message = "You have to write something in your title and post.";
          } else {
               mysql_query("UPDATE `topics` SET `text`='".$post."' WHERE `id`='".$r['id']."'");
               mysql_query("UPDATE `topics` SET `title`='".$title."' WHERE `id`='".$r['id']."'");
               header("Location: http://www.domain.com/view-post/".$r['id']."");
          }
     }
}
?>

图片转代码服务由CSDN问答提供 功能建议

可能重复:
已经由PHP发送的提醒 \ n

这是我当前的脚本。 该页面不会像我希望的那样重定向,而是刷新到当前页面。 该页面曾用于工作,但最近无缘无故地停止工作。 我在PHP 5.3

 &lt;?php 
 $ page =“Edit Topic”; 
require('top.php'); 
 $ var = safe  ($ _GET ['id']); 
 $ q = mysql_query(“SELECT * FROM` topics` WHERE`id` ='”。$ var。“'”); 
 $ r = mysql_fetch_array($ q)  ; 
 $ c = mysql_num_rows($ q); 
 $ user = mysql_fetch_array(mysql_query(“SELECT * FROM`users` WHERE`id` ='”。$ _ SESSION ['id']。“'”));  
 
if($ c == 0){
 echo“&lt; p&gt;此主题不存在。&lt; / p&gt;”; 
} elseif($ _ SESSION ['name']!= $ r [  'poster']&amp;&amp; $ user ['rank'] ==“会员”){
 echo“&lt; p&gt;这不是您的主题。&lt; / p&gt;”; 
}其他{
  if(isset($ _ POST ['enter'])){
 $ title = safe($ _ POST ['title']); 
 $ post = safe($ _ POST ['post']); 
 
  if($ post ==''|| $ title ==''){
 $ message =“你必须在你的标题中写一些东西并发帖。”; 
} else {
 mysql_query(“UPDATE` topics  `SET`text` ='“。$ post。”'WHERE`id` ='“。$ r ['id']。”'“); 
 mysql_query(”UPDATE` topics` SET`title` ='  “。$ title。”'在哪里 `='“。$ r ['id']。”'“); 
标题(”位置:http://www.domain.com/view-post/".$r['id']。“  “); 
} 
} 
} 
?&gt; 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

相关推荐 更多相似问题