English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I keep get the error message "Cannot modify headers, output started at......." blah blah blah. I’m a newbie web designer, been working with asp, however am doing a site that is Linux based and using PHP. I have been playing with various scripts in PHP like newsletters and login scripts and various other things. No matter what kind of script it is, (in PHP) i get this error message and its driving me mad. Already setup database and alls connected, then the first time i try to use the script live or login as an admin then i get this b***** error message. I have been battling for a week now and am seriously considering forgetting that PHP and Linux ever existed, unless someone can help me out here. I read its a problem occurred from white space at top page in question, but I looked at that and it seems fine...I have been getting this same error with whatever PHP script I try to implement, please, please, please. I decided to give PHP and Linux a chance, but I ain’t impressed so far.

2007-02-19 17:22:20 · 5 answers · asked by handmadethaibkk 1 in Computers & Internet Programming & Design

5 answers

Any time you attempt to use a function that needs to output it's information in the HTML header, you will get that error if ANY data at all has already been sent that is part of the BODY of the web page.

Note that this includes not only output from PHP (echo, print) but also HTML... including BLANK LINES and SPACES. So make sure that your opening

2007-02-20 10:57:56 · answer #1 · answered by Anonymous · 2 0

I think you are using session_start(); header("..."); or similar functions after displaying some output.
To get rid of this error, you can use following simple solution.
in the start of your page, add this line
ob_start();

and at the end of your page, add this line
ob_end_flush();

ob_start() turns on output buffer. So all the output is stored in this buffer and only headers are sent. When we call ob_end_flush(), the server sends all contents from buffer to client and flush the buffer.

2007-02-21 01:17:54 · answer #2 · answered by Atif Majid 3 · 0 0

Any calls to header(), setcookie(), or session_start() need to be done before anything else, or you'll get that error. Or - you can turn on output buffering. See the link for a discussion of how and why. Besides doing it inside your code, you may also be able to do it at the system configuration level, depending on how your server is set up and what permissions you have. Google "php output buffering" for more.

2007-02-20 02:59:41 · answer #3 · answered by injanier 7 · 1 1

Remember that header() must be called before any actual output is sent...
may be you are using any "echo" before the header().
if so then remove that echo and try again.
you will get redirect to the link without any error as' header all ready sent'.

2007-02-20 03:26:40 · answer #4 · answered by Shree J 2 · 0 1

... I thought u ment car headers i was so happy i can help u with that

2007-02-20 01:30:02 · answer #5 · answered by ... 2 · 0 2

fedest.com, questions and answers