PHP Developer Channel :: 討論園地

您尚未登入。

#1 2007-05-21 12:01:07

nanabee7
New member
註冊日期: 2007-05-17
文章數: 4

Cannot modify header information

執行到這行
header("location:/ecard.php");

會出現訊息
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\post.php:1) in C:\AppServ\www\post.php on line 36

之前也有爬文http://www.phpdc.com/bbs/t-p54.html

但我真的看不懂!!所以請教一下各位大大.

離線

 

#2 2007-05-21 17:02:13

nanabee7
New member
註冊日期: 2007-05-17
文章數: 4

Re: Cannot modify header information

我找了一下網路資源,改了output_buffering = Off ->On
也是不行!!


以下是我執行header的那支程式,想請問header那部份有什麼問題呢?
一直出現此訊息>"<
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\post.php:1) in C:\AppServ\www\post.php on line 53

<?php
  $note = $_POST["note"];
  $agent = $_POST["agent"];
  //$content = $_POST["content"];
  $current_time = date("Y年m月d日 H:i:s");

  // mysql 使用者
  $mysql_host ="127.0.0.1";
  // mysql 使用者
  $mysql_user ="root";
  // mysql 密碼
  $mysql_pass ="angela";
  // 資料庫名稱
  $mysql_db ="test";


//建立資料連接
$link = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
if (!$link) die("建立資料連接失敗");
           
//開啟資料表
$db_selected = mysql_select_db($mysql_db, $link);
if (!$db_selected) die("開啟資料庫失敗");
   
//執行 SQL 命令
$sql = "INSERT INTO lovenote(note, agent, notedate)
            VALUES ('$note', '$agent', '$current_time')";
  mysql_query("SET NAMES 'utf8'");            
$result = mysql_query($sql, $link);
if (!$result) die("執行 SQL 命令失敗");

//關閉資料連接
mysql_close($link); 
 
//將網頁重新導向
header("location:ecard.php");
exit();
?>

離線

 

#3 2007-05-24 11:47:59

nanabee7
New member
註冊日期: 2007-05-17
文章數: 4

Re: Cannot modify header information

隔天無更改程式之下,再測試即OK

我不知道問題在那裡.

離線

 

論壇頁尾

Web Hosting
PHP Developer Channel
Powered by PunBB 1.2.9
© Copyright 2002–2005 Rickard Andersson