1.11M Members

PHP Warning: Cannot modify header information - headers already sent by (output .....

Question Answered as of 6 Years Ago by WhiteLeo and JeniF
 
0
 

Thank you for the info guys

 
-1
 

you can change document encoding to "ansi" . always use powerfull editor same as dreamveaver or rapidphp for edit & change code.

In the HTTP protocol a server response consists of a group of headers followed by a body, separated by a single blank line (i.e. a line containing only a carriage-return). This warning message is produced by PHP if a program attempts to send an additional HTTP header after the separator (and hence all the headers) has already been sent.

By far the most common cause of this problem is that one or more PHP files contains characters (usually a space or an empty line) outside of the <?php and ?> tags. To fix the problem you should examine the PHP file indicated in the warning message and remove any blank characters at the beginning and end of the file. Some text editors, including some online file managers, are prone to automatically adding extraneous line-ending characters at the ends of files, particularly when not configured to do otherwise.

Remove the closing ?> tag at the end of your PHP files. It actually serves no useful purpose as the PHP interpreter knows that end-of-file means end-of-PHP too. Removing it means that any extra blank characters added by your editor will have no effect on the output generated and so will not prevent additional HTTP headers from being sent.

Turn output_buffering setting on php.ini to on to permanently remove this error

 
0
 

Thanx a lot JeniF...

Your suggesion helps me...

 
-1
 

can anyone help me? I'm with a problem to activate the plugin wp-postratings on my site. When I activate the plugin, the following error appears:

"Warning: Cannot modify header information - headers already sent by (output started at /home/universc/public_html/wp-content/plugins/wp-postratings/wp-postratings.php:2635) in /home/universc/public_html/wp-includes/pluggable.php on line 866"

how to solve this?

 
0
 

the thread is ol bud i'd like to share my persolnal solution. I got the (Warning: Cannot modify header information - headers already sent by) warning working with dotproject application and I read elsewhere that the bug may be empy spaces in the bottom os php code file. Tried to clean empty spaces and everything else and nothing. After call a friend to help he discovered some few blank characters in the end of php file code that was generating html undesirable code and therefore the warning..... hard to track "invisible" bugs like that.... best regards to all.

 
0
 

Fantastic, I was amazed and so relieved. My problem was refreshing the same page of listed results immediately after deleting one of them with a Form submit and this solution is the only one that works. Truely many thanks. Peter

<? ob_start(); ?>

<? ob_flush(); ?>

 
0
 

thanks jenif. it worked perfectly.

 
0
 

How do I fix the issue if I can't even log in as an admin?

 
0
 

Thank you Jeni and Jessie! This code and no extra spaces solved it!
Blessings,
Tadej

 
0
 

Thanks JeniF...your suggestions just worked like magic.

 
0
 

Thanx JeniF..
your solution still work til this day..

 
0
 

thnx
i am facing "header already sent" error message problem. when i search this out form these posts i have solved my problem.
Regards,
Azhar

 
0
 

Hi there
We are having a similar situation. One of the administrators of our website tried to add an affiliate widget from Amazon. Not sure where they put it but it is in the header and is the only thing available on the log in screen - I cannot log in to see the code or where it was added.

This is the error message:Warning: Cannot modify header information - headers already sent by (output started at /home/persue2/public_html/wp-content/plugins/amazon-auto-links/inc/amazonautolinks_initial_load.php:2) in /home/persue2/public_html/wp-includes/pluggable.php on line 881

When I try to log in: http://www.health2persue.com/wp-admin/ I can only see the above messagea nd teh widget image. How can I bypass this to log in and change or remove the code?

thank you

 
0
 

Thanks so much Jenif I tried your solution and it worked greatly ....thanks so much :)

as i put the following code at the top

<?php ob_start(); ?>

and the following code at the end of the file

<?php ob_flush(); ?>
 
0
 

thank you very much

 
0
 

Thank You Very Much

 
0
 

thanks for ob_start() and ob_flush() help

 
0
 
i have same problem
my code is.....please suggest???

thanx in advance....
--------------------------------------------------------------------------
Warning: Cannot modify header information - headers already sent by (output started at /home/content/15/9936915/html/jagruktimes-coin/show-category.php:1) in /home/content/15/9936915/html/jagruktimes-coin/show-category.php on line 21

Warning: Cannot modify header information - headers already sent by (output started at /home/content/15/9936915/html/jagruktimes-coin/show-category.php:1) in /home/content/15/9936915/html/jagruktimes-coin/show-category.php on line 22

---------------------------------------------------------

<?php ob_start();
        include_once("cone_inc.php");
        $flag_user=0;
$p=getParam("page",1);
$lowerlimit =0;
$upperlimit =20;
if ($p >1)
{
    $lowerlimit = $p*20-20;
    $upperlimit = $p*20;
}
    $cat_url = getParam("id","");
    $REQUEST_URI = $_SERVER['REQUEST_URI'];
    if(preg_match('/[\/]+/',$REQUEST_URI))
    $REQUEST_URI=preg_replace('/[\/]+/','/',$REQUEST_URI);
    $check_backslashes=substr($REQUEST_URI,-1);
    if(!(preg_match('/\..*/',$REQUEST_URI)))
    {
        if($check_backslashes != '/')
        {
            header("HTTP/1.1 301 Moved Permanently");
            header("Location:http://".$_SERVER['HTTP_HOST'].$REQUEST_URI."/");
            exit;
        }
    }

    $REQUEST_URI_NEW=$REQUEST_URI;
    $loc_url=mb_split("/",$REQUEST_URI_NEW);
    $page=1;
    $cnt = count($loc_url);
    $c = ($cnt - 2);  
    if (preg_match('/^(\d+)$/',$loc_url[$cnt-2]))
    {
         $page = $loc_url[$cnt-2];

         $c = ($cnt - 3);  
    }


    if($loc_url[1] && $loc_php[1]!="php")
    {
        $id = change_cPath($loc_url[$c]);
    }

$checkid = $id;

if ($id < 1)
{
  redirect("/");
}  
else
{
    $sql=q("SELECT cat_id,`cat_name`,`cat_total`,`cat_image`,  cat_fatherid, cat_description, cat_meta_title, left(cat_meta_description,250) meta_desc, left(cat_meta_keywords,250) meta_keyword FROM `cone_category`  where cat_id= $id");
     $cat = mysql_fetch_array($sql);
    $catname=$cat[cat_name];
    $catname_only = $cat[cat_name];
    $cat_father_id = $cat[cat_fatherid];
    $count = $cat[cat_total];
    $meta_title= $cat[cat_meta_title];
    $meta_desc= $cat[meta_desc];
    $meta_keyword= $cat[meta_keyword];
    $ct_desc= $cat[cat_description];
$page1html=$REQUEST_URI_NEW;
$pagination=pagmap_index($count,20,$page,getAllParams(array("page")),$page1html);
$paging = $pagination[url_bar];
$limit  = $pagination[sql_limit];
$bc = breadcrum($id,'jagruktimes.co.in');

$sql1=q("select cat_id, leaf_catid from cone_category where cat_id = $id");
    $cat1 = mysql_fetch_array($sql1);
    if($cat1[cat_id]==$cat1[leaf_catid])
    {
    $c = $cat1[cat_id];
    $checkcat = 1;


$checkurl = mysql_fetch_array(q("SELECT cat_fatherid FROM cone_category where cat_id=$checkid"));

if ($checkurl[cat_fatherid] != 0)
        {
$checkurlg = mysql_fetch_array(q("SELECT cat_fatherid FROM cone_category where cat_id=$checkurl[cat_fatherid]"));

$checkurl1 = $checkurlg[cat_fatherid];
if($checkurl1 == 0)
    {
$checkurl1 = $checkurl[cat_fatherid];
    }
        }
    else
        {
    $checkurl1 = $checkid;
        }

    }
    else
    {
    $checkcat = 2;
    $c = $cat1[cat_id].','.$cat1[leaf_catid];

$checkurl = mysql_fetch_array(q("SELECT cat_fatherid FROM cone_category where cat_id=$checkid"));
$checkurl1 = $checkurl[cat_fatherid];
if($checkurl1 == 0)
    {
$checkurl1 = $checkid;
    }



}

if($checkcat == 1)
    {
    //echo $checkcat;
    $sql=q("SELECT ad_id,ad_date_updated,ad_url,ad_city,ad_date,ad_cat_id,ad_user_mobile, ad_user_name, ad_title,left(ad_description,600) ad_desc,ad_has_picture FROM cone_ad where ad_show_flag=1 and ad_cat_id IN ($c) ORDER BY ad_date_updated DESC $limit");
    $count=mysql_num_rows($sql);
    if($count>0)
    {
        while ($ad = mysql_fetch_array($sql))
        {
             $date = date("l dS \of F Y  H:i:s",$ad['ad_date']);
                  //$cityn = mysql_fetch_array(q("SELECT city_description FROM  cone_city where city_id=$ad[ad_city]"));
               //$citname = mysql_fetch_array(q("SELECT cat_name FROM  cone_category where cat_id=$ad[ad_cat_id]"));
if($ad[ad_user_name])
              {
$ad_cont_name = '<p class="cb_name">'.$ad[ad_user_name].'</p>';
              }
if($ad[ad_user_mobile])
              {
$ad_mobile_no = '<p class="cb_no">'.$ad[ad_user_mobile].'</p>';
              }
            $desc = strip_tags($ad[ad_desc]);

if(strlen($desc) > 500) {
      $desc = preg_replace("/^(.{1,570})(\s.*|$)/s", '\\1...', $desc);
   }
//$desc  =  Unaccent($desc);
    if($ad[ad_has_picture]==1)
            {
            $pic = mysql_fetch_array(q("SELECT id,filename FROM cone_picture where pic_ad_id=$ad[ad_id]  and main=1"));
            $ads .= '<div onmouseover="javascript:this.style.background=\'#F5FBFE\'" onmouseout="javascript:this.style.background=\'#FFF\'" class="listingpad"><p class="imagebrd" align="center" style="border:1px solid #dedede;background:#FFF"><a href="/'.$ad[ad_url].'.html"><img src="/images/s-'.$pic[filename].'" border="0" alt="'.$ad[ad_title].'" ></a></p><div class="f2 ad_cnt"><div style="text-align:left;padding-bottom:4px;line-height:24px;font-size:20px"><a href="/'.$ad[ad_url].'.html">'.$ad[ad_title].'</a><br><span class="ndate">'.date('D j M Y H:i:s',$ad[ad_date_updated]).'</span></div><div style="line-height:21px">'.$desc.'</div></div><p class="seprate1"><br></p></div><div class="cb"></div>';
            }
            else
            {
            $ads .= '<div onmouseover="javascript:this.style.background=\'#F5FBFE\'" onmouseout="javascript:this.style.background=\'#FFF\'" class="listingpad"><div class="f2 ad_cnt" style="width:650px"><div style="text-align:left;padding-bottom:4px;line-height:24px;font-size:20px"><a href="/'.$ad[ad_url].'.html">'.$ad[ad_title].'</a><br><span class="ndate">'.date('D j M Y H:i:s',$ad[ad_date_updated]).'</span></div><div style="line-height:21px">'.$desc.'</div></div><p class="seprate1"><br></p></div><div class="cb"></div>';
            }
        }
    }
    else
    {
        $ads.="<br><br><br><div align=\"center\" class=\"m4 m1 c3 li bd4\"><b class=\"c1\"  style=\"color:#ff0000\">No News Found in this Category</b><br><br><br><br></div> ";
    }
    }


else 
    {

    $sql12=q("SELECT cat_id,leaf_catid,cat_name, `cat_full_name`, cat_name_for_url,cat_name_show_url, cat_name_show_url FROM `cone_category` WHERE `cat_fatherid` = $id order by PREORITY");
    while ($adnw = mysql_fetch_array($sql12))
                {
                $z++;       
                if ($z % 2 == 1)
                        {
                        $cbs = '';
                        }
                else
                        {

                        $cbs = '<div class="cb"></div><br>';
                        }
                    $ctgorywidnews .= '<div class="fl w310" ><div class="w100ps"><h3 class="fs120n mb5"><a href="/'.$adnw[cat_name_show_url].'/">'.$adnw[cat_name].'</a></h3>';


        $sqltt=q("SELECT ad_id,ad_url,ad_date_updated,ad_city,ad_date,ad_cat_id,ad_user_mobile, ad_user_name, ad_title,left(ad_description,350) ad_desc,ad_has_picture FROM cone_ad where ad_show_flag=1 and ad_cat_id IN ($adnw[leaf_catid])  ORDER BY ad_date_updated desc limit 3");
        $countt=mysql_num_rows($sqltt);

        $k=0;
        if($countt>0)
            {
                $adcnt = 0;
                while ($sqlttr = mysql_fetch_array($sqltt))
                    {

                        $descp = strip_tags($sqlttr[ad_desc]);
                        if(strlen($descp) > 300) 
                            {
                        $descp = preg_replace("/^(.{1,200})(\s.*|$)/s", '\\1...', $descp);
                            }
                        //$descp  =  Unaccent($descp);

        if($sqlttr[ad_has_picture]==1)
            {
            $pic1 = mysql_fetch_array(q("SELECT id,filename FROM cone_picture where pic_ad_id=$sqlttr[ad_id]  and main=1"));
            $image = '<img src="/images/s-'.$pic1[filename].'" alt="'.$sqlttr[ad_title].'" class="mr10" align="left" width="110" height="85" style="border:1px solid #f4f4f4">';
            }
            else
                {
            $image = '';    
                }


                $k++;
                if ($k == 1)
                    {
    $ctgorywidnews .= '<div class="mb5"><div class="lh18" style="padding-top:4px;padding-bottom:4px"><a href="/'.$sqlttr[ad_url].'.html"><b>'.$sqlttr[ad_title].'</b></a></div> <a href="/'.$sqlttr[ad_url].'.html">'.$image.'</a> <span class="fs85 introTxt">'.$descp.'</span><br><span class="ndate">'.date('D j M Y H:i:s',$sqlttr[ad_date_updated]).'</span> </div> <div class="cb ">&nbsp;</div><div class="fs80 mt10"><ul class="dotUL" type="disc">';
                    }
                    else
                    {
    $ctgorywidnews .= '<li style="line-height:18px;margin-top:8px"><a href="/'.$sqlttr[ad_url].'.html">'.$sqlttr[ad_title].'</a></li>';
                    }

                    }

    $ctgorywidnews .= '</ul></div> <div class="tar"><a href="/'.$adnw[cat_name_show_url].'/" class="fs90">'.$adnw[cat_name].' की और ख़बरें <b class="lrgFnt">»</b></a></div></div></div>'.$cbs;


                    }
        else
        {
        $ctgorywidnews .= '</div></div>'.$cbs;
        }

            }   
    }


}
if ($p_val[3] !='')
{
$p_val = ' - Page '.$p_val[3];
}
else
{
    $p_val = '';
}
 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?php echo $meta_title?><?php echo $p_val?></title>
<?php 
if ($p_val[3] =='')
{
if($meta_desc)
{
echo "<meta name=\"description\" content=\"$meta_desc\">"; 
}
if ($meta_keyword)
{
echo "<meta name=\"keywords\" content =\"$meta_keyword\">"; 
}
}


?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="/jagruk-times.css" type="text/css" rel="stylesheet">
<script src="/javascript/common.js" language="javascript" type="text/javascript"></script>
<script src="/javascript/ajax_request.js" language="javascript" type="text/javascript"></script>
</head><body topmargin="0"><div id="wrapper"><div class="c3 pt1 headmin">
<div class="fl" style="width:310px"> <a href="/"><img width="310" border="0" height="85" class="none" alt="Jagruk Times" src="/images/jagruk_times_logo.gif"></a><br>
<?php 
$timezone = "Asia/Calcutta";
if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
echo '<div style="font-family:arial;font-size:11px;color:#9b9b9b;position:absolute;margin-top:-5px;padding-left:20px">'.date('D j M Y H:i:s').'</div>';?> 
<div class="cb">&nbsp;</div>
</div>
<div class="fr tar fs70 cr1 ttad" >
<div style="font-size:70%; text-align:right; color:#CCCCCC;">विज्ञापन</div>
<?php echo $banner_top?>
</div>
<div class="cb" style="height:15px;">&nbsp;</div>
</div>
<div class="cb" ></div>
<div class="vSprt nMidc">
<div class="vSprt nLftc">
<div class="vSprt nRgtc">
<div id="header_color" style="padding-left:13px;">
<ul id="mNav">
<?php
$c_states = '';
$c_national = '';
$c_international = '';
$c_business = '';
$c_games = '';
$c_entertainment = '';
$c_lifestyle = '';
$c_sahitya = '';
$c_religion = '';
$c_adhiyatm = '';
$c_jokes = '';

if($checkurl1 == 201){$c_states = 'open';}
if($checkurl1 == 195){$c_national = 'open';}
if($checkurl1 == 242){$c_international = 'open';}
if($checkurl1 == 246){$c_business = 'open';}
if($checkurl1 == 256){$c_games = 'open';}
if($checkurl1 == 225){$c_entertainment = 'open';}
if($checkurl1 == 232){$c_lifestyle = 'open';}
if($checkurl1 == 268){$c_sahitya = 'open';}
if($checkurl1 == 274){$c_religion = 'open';}
if($checkurl1 == 282){$c_adhiyatm = 'open';}
if($checkurl1 == 305){$c_jokes = 'open';}

?>
<li><a href="/" style="cursor:hand;"><span>होम पेज</span></a></li>
<li class="<?php echo $c_states ?>"><a href="/states/" style="cursor:hand;"><span>राज्य</span></a></li>
<li class="<?php echo $c_national ?>"><a href="/national/" style="cursor:hand;"><span>देश</span></a></li>
<li class="<?php echo $c_international ?>"><a href="/international/" style="cursor:hand;"><span>विदेश</span></a></li>
<li class="<?php echo $c_business ?>"><a href="/business/" style="cursor:hand;"><span>व्यापार</span></a></li>
<li class="<?php echo $c_games ?>"><a href="/games/" style="cursor:hand;"><span>खेल</span></a></li>
<li class="<?php echo $c_entertainment ?>"><a href="/entertainment/" style="cursor:hand;"><span>मनोरंजन</span></a></li>
<li class="<?php echo $c_lifestyle ?>"><a href="/lifestyle/" style="cursor:hand;"><span>लाइफस्टाइल</span></a></li>
<li class="<?php echo $c_sahitya ?>"><a href="/sahitya/" style="cursor:hand;"><span>साहित्य</span></a></li>
<li class="<?php echo $c_religion ?>"><a href="/religion/" style="cursor:hand;"><span>धर्म मंच</span></a></li>
<li class="<?php echo $c_adhiyatm ?>"><a href="/adhiyatm/" style="cursor:hand;"><span>अध्यात्म</span></a></li>
<li style="position:relative; left:0px; top:0px;" class="<?php echo $c_jokes ?>"><a href="/jokes/" style="background:none;"><span>चुटकुलें</span></a></li>

</ul>
</div>
</div>
</div>
</div>
  <div class="cb" ></div>

  <!--Header Section Ends-->

<div class="left_part" >
<p class="times_breadcromb"><?php echo $bc; ?></p>
<h1 class="times_heading"><?php echo $catname; ?></h1>


<div class="cb"></div>

<?php 

if ($checkcat == 1)
{
echo $ads;
}
else
{
echo $ctgorywidnews;
}
?> 

<?php
$p_val = $_SERVER['REQUEST_URI'];
$p_val = explode("/", $p_val);
if ($checkcat == 1)
{
echo '<div style="padding-top:10px;text-align:right;font-size:14px;padding-bottom:12px"><b>'.$paging.'</b></div>'; 
}
?>

</div>
<?php
include_once("right_navigation.php");
?>  
<p class="cr" style="clear:both"></p>
<?php
  include_once("cone_footer.php");
?>  
 
0
 

I know this is an old thread but still healping out..

Thank you

 
0
 

Thank you very much JeniF, the obstart() and obflush() solved my problem...

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: