Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why do I get “Can send headers – Headers already sent at line nnn”?

headers line nbsp nnn send sent
0
Posted

Why do I get “Can send headers – Headers already sent at line nnn”?

0

There cannot be any output sent to the browser before using sessionStart(), sessionRegister() or header(). While you may not have meant to do so, something in the php script has sent output to the browser. Most often this is white space (spaces, new lines, etc) that are perhaps there for readability. The following php code will cause this error: 1: 2: 3: 7: The white space at line 2 is output to the browser, so the sessionStart() at line won’t be allowed and you’ll receive the “headers already sent message.” Here are two solutions: 1. Find the offending white space, and remove it. Note that it could be in an include or require statement. php tells you where the output started, look there. 2. Use output buffering. See the manual at http://www.php.net/manual/en/ref.outcontrol.php To add on to that, it’s okay to have white space within php tags, but if you are using sessions, or the header() function, no text can be sent to the browser, includin

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.