2013-03-21 28 views
-2
Warning: Cannot modify header information - headers already sent by (output started at /home/apexwyxa/public_html/click4jalandhar.in/u-banner.php:14) in /home/apexwyxa/public_html/click4jalandhar.in/conn.php on line 115 

以上是我的錯誤,下面是我的PHP代碼我越來越不能獲得頭信息的錯誤,但我不能能解決

function update_name($fname, $lname, $u) 
     { 
      include "db.php"; 
      $query = "update users set firstname='$fname', lastname='$lname' where user_ID='$u'"; 
      $result = mysql_query($query); 
      if($result) 
      { 
       $msg = "Name updated"; 
      } 
      else 
      { 
       $msg = "Error => ".mysql_error(); 
      } 
      header("location:userinfo.php?x=$msg"); 
     } 
     function update_uname($username, $u) 
     { 
      include "db.php"; 
      $query = "update users set username='$username' where user_ID='$u'"; 
      $result = mysql_query($query); 
      if($result) 
      { 
       $msg2 = "Username updated"; 
      } 
      else 
      { 
       $msg2 = "Error => ".mysql_error(); 
      } 
      header("location:userinfo.php?x=$msg2"); 
     } 
     function update_email($email, $u) 
     { 
      include "db.php"; 
      $query = "update users set email='$email' where user_ID='$u'"; 
      $result = mysql_query($query); 
      if($result) 
      { 
       $msg3 = "Email updated";  
      } 
      else 
      { 
       $msg3 = "Error => ".mysql_error(); 
      } 
      header("location:userinfo.php?x=$msg3"); 
     } 
     function update_pass($old_pass, $new_pass, $u) 
     { 
      include "db.php"; 
      $xquery = "select * from users where user_ID = '$u'"; 
      $xresult = mysql_query($xquery); 
      $xnum = mysql_num_rows($xresult); 
      if($xnum>0) 
      { 
       while($xrow = mysql_fetch_array($xresult)) 
       { 
        extract($xrow); 
        if($xrow[8]!=$old_pass) 
        { 
         $msg4 = "Your current password is not correct/matching";  
         header("location:userinfo.php?x=$msg4"); 
        } 
        else 
        { 
         $query = "update users set password='$new_pass' where user_ID='$u' and password='$old_pass'"; 
         $result = mysql_query($query); 
         if($result) 
         { 
          $msg4 = "Password updated"; 
         } 
         else 
         { 
          $msg4 = "Error => ".mysql_error(); 
         } 
         header("location:userinfo.php?x=$msg4"); 
        } 
       } 
      } 
     } 
+3

請參閱'相關章節---------------------------------> – 2013-03-21 14:39:31

+1

您不能使用'header ()'如果_any_輸出已經被創建。 – Adrenaxus 2013-03-21 14:40:45

+0

嘗試查看在結束標記之後文件末尾是否有額外的空格?>如果它無助於嘗試一起移除結束標記。 – Adidi 2013-03-21 14:40:56

回答

2

看一看這個話題。 Wordpress - Error: headers already sent

出現此錯誤的原因是,當你調用header()函數前輸出任何東西。

+2

這應該是我認爲的評論:) – 2013-03-21 14:44:50

+0

謝謝,仍然習慣於網站的佈局/工作。 :) – llanato 2013-03-21 14:49:23

0

您可以只有設置標題爲單個字符發送到瀏覽器。改用JavaScript重定向。

相關問題