-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");
                    }
                }
            }
        }
4

2 に答える 2

2

このトピックを見てください。 Wordpress - エラー: ヘッダーは既に送信されています

このエラーが発生する理由は、header() 関数を呼び出す前に何かを出力した場合です。

于 2013-03-21T14:41:48.120 に答える
0

ブラウザに送信される単一の文字の前にのみヘッダーを設定できます。代わりに JavaScript リダイレクトを使用してください。

于 2013-03-21T14:49:12.533 に答える