-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 回答