PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Its seem my header will not work? I'm including this file into my site layout and thats wot i think is makin the error as it works when i just open the file outside of the layout. I've use loads of header's in my site and they all work but this 1 doesnt?
is there an easy answer? or anything else i can use instead of Header?
I guess you will all notice there there is nothing in else but this is because its for a post pages and all my post get add to my page in html below this code so thats not importent?
Make sure you're not sending any output to the browser prior to the redirect (even headers). Also make sure that your not accidentally sending any blank lines or characters. Hope that helps.
Warning: Cannot add header information - headers already sent by (output started at /fileserver/webserver/no-order/index.php:6) in /fileserver/webserver/no-order/_message/posts.php on line 6
ob_start(); basically starts saving all the output that your script creates, and places it into a buffer. When your code is all done, and hits the ob_end_flush statement, it spits it all out at once. I've found this to be a big help, especially when doing header_location calls, and content_type stuff.
I had a similar problem the other day. You'll find the answer in one of the first few posts, called, "Sticky: Before Post Read: Warning: Cannot add header information." It's all there - believe me. And really, it is that simple.
Darkside, I've been using the ob start and ob end flush in all my php code, and haven't had any downsides. I've also used the ASP equivalent that does the same thing, and nothing bad has ever come of it.
The only time I don't use it is in rare instances when I want to display insane amounts of data, i.e. one asp project has a page that displays a dump of a database with 400 columns and about 20000 rows.. Not locking the buffer lets you see visible progress as the whole thing is being sent. But 99% of the time, it seems like a good thing to use.