Jump to content

[SOLVED] Warning: Cannot modify header information - headers already sent by (output star


jaxdevil

Recommended Posts

I am trying to add some include data in creloaded. The problem is on certain pages it appears to be sending the information I am adding twice, which I believe is causing it to break. The error message I get is: "Warning: Cannot modify header information - headers already sent by (output started at /home/whole/public_html/includes/template_application_top.php:54) in /home/whole/public_html/includes/functions/visual_verify_code.php on line 26" and line" and the line it is talking about is:

 

require_once($_SERVER['DOCUMENT_ROOT'].'/l_border.php');

 

I have tried it without using the include statement, so thats not it because originally I just had the data from the include file directly on the page, and it was erroring out right where the data was. Its not the data because I have tried it with just a php echo "<br>", and with my short added code, both give the same error, so its not the code contents but the fact that there is code at all. I am assuming creloaded loads template_application_top.php multiple times, what I need to do is limit this require/inclusion/however we do it to load only once per page. I tried with this code:

 

ob_start();

require_once($_SERVER['DOCUMENT_ROOT'].'/l_border.php');

ob_end_flush();

 

But that didn't change anything. Anyone know how I can limit that data to only being pulled once, that way I don't get the 'headers already sent' error?

 

Thanks,

SK

A lot of stuff, its CRELoaded (a version of oscomerce). Personally I think it is a bad program. The template_application_top.php checks to see if there is template selected in the control panel and if so it loads the corresponding template files for whatever page you are on. It is the only file I could find that I could add my html for the side borders and they would be in the right place. If anyone has a better way for me to add my borders or a better file let me know that also, either way, I just need to have my borders and not have the pages error out. Below is the way I add borders, the l_border.gif and r_border.gif are the border images (left and right respectively):

 

<center>
<table cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td background="/images/l_border.gif" height="100%" width="27">
</td>
<td align="center">

 

Thats what I put in the template_application_top.php. Below is what I put in the application_bottom.php

 

</td>
<td background="http://<?=$_SERVER[HTTP_HOST]?>/images/r_border.gif" height="100%" width="27">
</td>
</tr>
</table>

 

Really what would work perfect is if there is a bit of code I can enclose the require/include/whatever statement within that will only let it be read/displayed/run one time. Or if there is away to make it not be included if I am on certain pages (like this one that errors out).

 

visual_verify_code.php line 26 is doing something the sends a header, such as a redirect, cookie... Headers cannot be sent after ANY content has been output to the browser. To use output buffering to solve this, the ob_start(); statement must be placed before the first content is output.

Thank you. I figured out where I could place the html code without it making the page distorted or causing that "headers already sent" error. In the /templates directory I went to the folder of the template we are using and on the file main_page.tpl.php at the top, rigt under the <body> tag I added the html that was in template_application_top.php , I left the application_bottom.php as is and it is working fine.

 

Thanks for all the help, I appreciate it!

 

SK

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.