Cannot modify header information error.

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
Sniperbot
Registered User
Posts: 50
Joined: Thu Aug 21, 2008 2:02 pm
Location: Modesto, CA
Name: Rob Ert
Contact:

Cannot modify header information error.

Post by Sniperbot »

Im getting this error on a fresh install. Is the problem in my main.php page? It was working fine with phpbb3.04 now when I changed host and was starting a new board from scratch, I get this error and distorts my page. I'm still using all the same site files I had before. The board works fine if I log in but my page looks like crap.

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home2/siccrecc/public_html/main.php:9)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home2/siccrecc/public_html/main.php:9)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /home2/siccrecc/public_html/main.php:9)
This is how distorted it looks.
Image

Im not sure if its a problem with the main.php or if it could have something to do with the sessions.php. Line 1007 in the sessions page is

Code: Select all

header('Set-Cookie: ' . $name_data . (($cookietime) ? '; expires=' . $expire : '') . '; path=' . $config['cookie_path'] . $domain . ((!$config['cookie_secure']) ? '' : '; secure') . '; HttpOnly', false);
if I add // in front of that code it fixes the problem but my cookies obviously don't work and can't stay logged in if I navigate. So if I don't know if that is the problem.

The working site should look like thisImage
Like I said, it was working fine with phpbb 3.04 but once I upgraded, problem came up. My main.php page doesnt have the actual login session info, it has 3 php include pages, 1 that has the session login info.
User avatar
ric323
Former Team Member
Posts: 22910
Joined: Tue Feb 06, 2007 12:33 am
Location: Melbourne, Australia
Name: Ric
Contact:

Re: Cannot modify header information error.

Post by ric323 »

What is main.php ?
That is not a standard phpBB file, and the problem is in there.
Pasting the actual code into a code box here would help.
The Knowledge Base contains solutions to many common problems!
How to fix "Doesn't have a default value" and "Incorrect string value: xxx for column 'post_text' " errors.
How to do a clean re-install of the latest phpBB3 version.
Problems with permissions? Read phpBB3 Permissions
Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Re: Cannot modify header information error.

Post by Pony99CA »

Are you sure that you didn't edit any of the PHP files? That error usually occurs because a line was written to the HTTP response before phpBB got to write the HTTP headers. This can happen for something as simple as a blank line at the top of one of the files.

So look in main.php for anything strange. The problem was only detected in session.php, but it probably occurred in main.php.

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.
User avatar
Sniperbot
Registered User
Posts: 50
Joined: Thu Aug 21, 2008 2:02 pm
Location: Modesto, CA
Name: Rob Ert
Contact:

Re: Cannot modify header information error.

Post by Sniperbot »

ric323, main.php is the main page in my site which only includes 3 inlcudes. look.

Code: Select all

<html>
<head>
<title>Siccness Records 2009</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="Siccness Records, Siccness, Sicc, Sicc Rec, Sniper, Double G, Fatal, Lil Chill, AC Skrill, sickness, siccmade">
<meta name="description" content="Siccness Records Underground Musicc. Download free music and buy your favorite Sicc Rec albums.
">
</head>
<body bgcolor="#333333" background="images/body.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (index.psd) -->
<p>&nbsp;</p>
<div align="center"></div>
<table width="851" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
  <tr> 
    <td colspan="2"> <img src="images/top.jpg" alt="" width="671" height="97" border="0" usemap="#Map2"></td>
    <td width="179" rowspan="3" align="center" valign="top" background="images/right1.jpg"><br> 
      <?php include('divLogin.php'); ?>
    </td>
    <td width="1"> <img src="images/spacer.gif" width="1" height="97" alt=""></td>
  </tr>
  <tr> 
    <td colspan="2"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="671" height="33">
        <param name="movie" value="flash/top.swf">
        <param name="quality" value="high">
        <embed src="flash/top.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="671" height="33"></embed></object> 
    </td>
    <td> <img src="images/spacer.gif" width="1" height="33" alt=""></td>
  </tr>
  <tr> 
    <td width="377" rowspan="2" align="center" valign="top" background="images/middle1.jpg"> 
      <?php include('divMiddle1.php');?>
    </td>
    <td width="294" rowspan="2"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="294" height="179">
        <param name="movie" value="flash/Middle2.swf">
        <param name="quality" value="high">
        <embed src="flash/Middle2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="294" height="179"></embed></object></td>
    <td> <img src="images/spacer.gif" width="1" height="140" alt=""></td>
  </tr>
  <tr> 
    <td rowspan="2" align="center" valign="top" background="images/right2.jpg"> 
      <?php include('divRight2.php');?>
    </td>
    <td> <img src="images/spacer.gif" width="1" height="39" alt=""></td>
  </tr>
  <tr> 
    <td colspan="2" rowspan="2"> <img src="images/middle3.jpg" alt="" width="671" height="271" border="0" usemap="#Map"></td>
    <td> <img src="images/spacer.gif" width="1" height="48" alt=""></td>
  </tr>
  <tr> 
    <td align="center" valign="top" background="images/right3.jpg"><br>
      <img src="divRandom.php" /> 
    </td>
    <td> <img src="images/spacer.gif" width="1" height="223" alt=""></td>
  </tr>
</table>
<!-- End ImageReady Slices -->
<map name="Map">
  <area shape="rect" coords="309,158,659,257" href="merchandise.php">
  <area shape="rect" coords="53,57,245,247" href="downloads.php">
  <area shape="rect" coords="192,115,213,161" href="downloads.php">
</map>
</body>
</html>

<STYLE type="text/css">
<!--
BODY
{
scrollbar-face-color: #000000;
scrollbar-highlight-color: #FFFFFF;
scrollbar-3dlight-color: #999999;
scrollbar-darkshadow-color: #CCCCCC;
scrollbar-shadow-color: #666666;
scrollbar-arrow-color: #FFFFFF;
scrollbar-track-color: #333333;
}
-->
</STYLE>
and divLogin.php is

Code: Select all

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<meta name="Robots" content="NOINDEX" />
<meta http-equiv="PRAGMA" content="NO-CACHE" />
<link rel="StyleSheet" type="text/css" href="StyleSheet.css">
<title>Siccness Records</title>
</head>
<body bgcolor="#333333" link="#CCCCCC"><html>
<head>
<title>Siccness Records</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">









<?php
function display_login_box()
{
   echo "<div class='LoggedOut'>";
   echo '<center>
   Please Log In<br /><form method="POST" action="forum/ucp.php?mode=login">
   <p>Username: <br /><input type="text" name="username" size="15"><br/>
   Password: <br /><input type="password" name="password" size="15"></font><br/>
   <font color="#FFFFFF" size="1">Remember Me?</font><input type="checkbox" name="autologin name="remember" value="1" checked=yes"><br /><br />
   <input type="submit" value="Login" name="login">
   <input type="hidden" name="redirect" value="../main.php"><br /><br /><a href="register.php">Register Here</a><br><br>Forgot Password?
   </p></form>';

}


define('IN_PHPBB', true);
$phpbb_root_path = 'forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . '/includes/functions_display.' . $phpEx);


// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$my_avatar = get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']);
$user->get_profile_fields($user->data['user_id']);






if($user->data['is_registered'])
 {



  //User is already logged in

echo "<div class='Welcome'> ";
echo "Welcome Back!<br /><font color=#00C6FF size=2><b>";


echo "<table width='167' border='0' bgcolor='#000000'>
  <tr>
    <td><div align='center'><font color='#00FF00' size='2'>" . $user->data['username'];
echo "</font></div></td>
  </tr>
</table>";





   echo "<div class='Loggedin'>";


//Users Avatar
{
if($my_avatar==true)
{
echo($my_avatar);
}
}
// Changed includes/function_display.php                           CHANGED: directory, check url
//return '<img src="exforum/images/avatars/no_avatar.gif" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';

//Also in includes/functions.php                                    CHANGED: 3 to 0
//$redirect = meta_refresh(0, $redirect);

echo '</b></font><br /><a href="profile.php"><font color="#FFFFFF" size="1">Edit Profile</font></a>';





//Users New Messages
$l_message_new = ($user->data['user_new_privmsg'] == 1) ? $user->lang['NEW_PM'] : $user->lang['NEW_PMS'];
$l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']);
        echo '<br /><br /><font color=#FFFFFF size=2><a href="' . append_sid("messages.php") . '">' . $l_privmsgs_text . '</a><br />';




//Log Out
echo '</b></font><br /><br /><br /><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id ) . '"><a href="logout.php?redirect=main.php"><center><font color="#FFFFFF" size="1">log out</font></a><br />';





//Time and Date of User
//echo '<br /><font size=1 color=#FFFFFF>' . $user->format_date(time());
}





 else
 {
  $username = request_var('username', '', true);
  $password = request_var('password', '', true);
  $autologin = (!empty($_POST['autologin'])) ? true : false;

  $result = $auth->login($username, $password, $autologin);

  if ($result['status'] == LOGIN_SUCCESS)
  {

    //User was successfully logged in
    //Redirect to the page they were viewing
    $redirect = request_var('redirect', "index.php");


    // append/replace SID
    $redirect = reapply_sid($redirect);

    meta_refresh(0, $redirect);
   }
   else
   {
    display_login_box();
   }

 }
?>
</div>
</div>
I don't think the other 2 php pages have anything to do with it. They are just info pages with text.
Pony99CA, yes Im sure i didn't edit any files. I wanted to get it working right first before I made any changes to the site.
Pony99CA
Registered User
Posts: 4783
Joined: Thu Sep 30, 2004 3:13 pm
Location: Hollister, CA
Name: Steve
Contact:

Re: Cannot modify header information error.

Post by Pony99CA »

Sniperbot wrote:ric323, main.php is the main page in my site which only includes 3 inlcudes. look.

Code: Select all


Pony99CA, yes Im sure i didn't edit any files. I wanted to get it working right first before I made any changes to the site.[/quote]
The problem seems obvious to me (and should be to you after my first post ;)).  Your [b]main.php[/b] has probably already caused the page headers to be generated, so when [b]session.php[/b] tries to write the headers, they're already there, hence the error.

phpBB's [b]overall_header.html[/b] file contains the HTML, HEAD and BDOY tags, too, so your [b]main.php[/b] is duplicating those.  You probably need to move all of your header stuff into [b]overall_header.html[/b] and stop stepping on phpBB's toes.  :D

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.
User avatar
Sniperbot
Registered User
Posts: 50
Joined: Thu Aug 21, 2008 2:02 pm
Location: Modesto, CA
Name: Rob Ert
Contact:

Re: Cannot modify header information error.

Post by Sniperbot »

The part that I don't understand is, why did it work flawlessly before with the phpbb 3.04. I didn't change anything just moved host and started a new board and then the problem occoured, thats why I was stuck.

So on I blanked everything out on the main.php page and only left the login include which leaves the login box without the error. So im like, ok it works without errors with the login only but when I go to a different page, I get the same error on another page. Seems to be a problem on all my pages :( Im getting to the point where im just gonna remove the login from my site and just leave it in the forum cuz its killing me.
User avatar
Sniperbot
Registered User
Posts: 50
Joined: Thu Aug 21, 2008 2:02 pm
Location: Modesto, CA
Name: Rob Ert
Contact:

Re: Cannot modify header information error.

Post by Sniperbot »

Well I still haven't fixed the problem, but I noticed something strange, if I go directly to the site
http://www.siccrec.com/main.php its distorted, but if I visit the forum first even for just 1 second
http://www.siccrec.com/forum then back to the main site, the problem fixes. The site then stays good until of course I clear the cookies. Anybody have a clue why? Is my main.php missing something or what.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52845
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Cannot modify header information error.

Post by Brf »

The phpbb login code needs to be at the very top of the page, before you generate any HTML.You might have thought it worked on your old forum if your server had error messages suppressed.
User avatar
Sniperbot
Registered User
Posts: 50
Joined: Thu Aug 21, 2008 2:02 pm
Location: Modesto, CA
Name: Rob Ert
Contact:

Re: Cannot modify header information error.

Post by Sniperbot »

That is very interesting, the phpbb login code is in a separate page, Its just an "include" page. So I messed with it a bit and included it within the main.php, it did fix the horrible distortion but I have 1 little problem, when I log in, it says welcome then my name but it also still shows the login boxes. So close to fixing this problem, well at least I fixed my main problem. Any ideas?
User avatar
Sniperbot
Registered User
Posts: 50
Joined: Thu Aug 21, 2008 2:02 pm
Location: Modesto, CA
Name: Rob Ert
Contact:

Re: Cannot modify header information error.

Post by Sniperbot »

Well after hours of playing with it, I finally fixed my site :D Well the main page, even though I get the same error for my other pages, I know how to fix it so I have lots of work to do. Thanks a lot Brf, your quick reply made a big difference.
Locked

Return to “[3.0.x] MOD Writers Discussion”