Hi,

I have built an entire site with my localhost on my computer, as you do. and everything has worked fine. I have no issues. and still dont'

However, I just uploaded it, and am getting this error:

Warning: Cannot modify header information - headers already sent by (output started at /home2/quccocom/public_html/bizzinet/includes/head.php:5) in /home2/quccocom/public_html/bizzinet/main/includes/functions/f32.php on line 116

This is what I have on that line (line 116):

header ("refresh:0;url=join.php?join=1&site=$site");
	exit;

I have searched and everyone keeps saying that you have to remove the whitespace, but in head.php on line 5. there is no whitespace. it's just <?php code... ?>

I have

header ("refresh:0;url=join.php?join=1&site=$site");

of some description about 200-300 times in my site, and they are all in include files. with whitespace I assume.

Why would this work on my localhost, but not when I upload it?

Thanks for you help

It isn't just whitespace, it is anything that generate output to the browser. That could be an echo or a session statement or other things. Please post the first 5 or 6 lines of head.php

I actually found the answer:

All you have to do is alter the php.ini file:
Change:
output_buffering:???
to
output_buffering=4096

CHANGE

output_buffering = OFF
to
output_buffering = On


This makes all those ridiculous errors go away and makes it all work correctly.

Hope this helps someone else. :)

Thanks for posting :)

By turning on output buffering you've just bypassed the problem as output is stored until your script finishes or ob_flush() is called.
Somewhere in your script something is been written before you send the header.

By turning on output buffering you've just bypassed the problem as output is stored until your script finishes or ob_flush() is called.
Somewhere in your script something is been written before you send the header.

What do you mean?

There was heaps of stuff written before I change the header. There always is. Whats the point of refreshing the header or redirecting at the top of a page? unless thats all your doing.
I use that function to refresh the page after someone submits a form or changes something on a page. that way it only refreshes the part they change. well it seems to anyway.

hmm, I think you're miss interpreting what's going on. The header function adds or replaces HTTP headers which is sent by the HTTP server before any output is sent to the browser i.e. your form or the page.
When someone submits a form the browser submits this information back to the web server which runs your script in full once again - unless you're using AJAX or the form is within a frame / iframe the whole page is sent back to the browser where it is rendered.

What you've done here is to cache the output of your script so that when the browser submits the form data and you're php script runs once again all of its output is stored in a buffer. So when you add the HTTP refresh header (which isn't supported by all browsers by the way and is a proprietary extension) nothing has yet been sent to the browser so it works.
Using output_buffering will cause your server to use much more memory than it has to and can cause performance problems.

hmm, I think you're miss interpreting what's going on. The header function adds or replaces HTTP headers which is sent by the HTTP server before any output is sent to the browser i.e. your form or the page.
When someone submits a form the browser submits this information back to the web server which runs your script in full once again - unless you're using AJAX or the form is within a frame / iframe the whole page is sent back to the browser where it is rendered.

What you've done here is to cache the output of your script so that when the browser submits the form data and you're php script runs once again all of its output is stored in a buffer. So when you add the HTTP refresh header (which isn't supported by all browsers by the way and is a proprietary extension) nothing has yet been sent to the browser so it works.
Using output_buffering will cause your server to use much more memory than it has to and can cause performance problems.

Ohh, ok.

So why would all my site work in my local host fine, but when I upload it to the proper server, it breaks?

As I am having the exact same issue with the back end of the site. I can now not log in... and the exact same warning are coming up.

Do you know if there is something I can do to fix it? without going through my 100s of include files.

OK,

I also found another solution.
This is if you have heaps of include files with separate code in each one and want to refresh the page when a particular form is submitted. or something along those lines.

instead of using the header() functions.

simply replace it with:
echo "<meta http-equiv='refresh' content='0;URL=main/dash.php'>";

I have just swapped all my header functions with this and everything works great. I also turned output_buffering = OFF. So now I know that this will work everywhere. and not screw up other things.

I hope this helps someone in the future. as it took me hours (about 10) to work this out.

Good luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.