Help in PHP function

by 5 replies
6
Hi!!
I have just started the programming web development. I face the problem with the header function. The function doesn't redirect. Found this error.

Warning: Cannot modify header information - headers already sent by (output started at /home/kabeet/public_html/flash/page_add.php:4) in /home/public_html/page_add.php on line 72

Please help.
#programming #function #php
  • This means that you have already outputted to the page before the re-direct was actioned. Somewhere in the code above that line you have echo'd something to the page. Without seeing the code though I wouldn't be able to give you any further info.

    Does the page still re-direct, but displays that message?
  • As Andy says and the error implies; headers must be sent before any output. Make sure nothing, not even a whitespace is sent before you try to modify header information.
  • Agreed - the header function must be the first line in the code that produces any output.

    That doesn't imply that it must be the first line in the actual code, it can be the 400th line as long as the preceding 399 lines don't actually produce any output.

    Post a sample of the code you're writing so that we can have more details.


    Bill

  • This error means there has already been sent. check line 72 of the page_add.php function. these error are pretty good ad pointing you to the correct line. the header has to be the first output on the web page. Even a stray char will cause this error.
  • Hi, I found that reply on another forum, and I find it will help:
    On line 72 of the /home/public_html/page_add. php file you have already sent information back to the browser. Most likely via echo or print. Then later in the flow of the program you have tried to use the header function but since the header has already been sent to the browser it can not be modified. So pretty much just what the error says.

Next Topics on Trending Feed

  • 6

    Hi!! I have just started the programming web development. I face the problem with the header function. The function doesn't redirect. Found this error.