View Full Version : header? How?

11-27-2003, 02:54 PM

i have a it problem with including file

when ever i include a file within a page its says

warning cannot modify header .header already sent..

how come?i didnt submitted any data..the file i included is collecting data form the visitor..

is it related to the location of the inclusion code ?i included the code at the tenth line on the page.


11-27-2003, 02:57 PM
You must have the headers sent before any HTML. Even the smallest little bit of text. It must come before everything. If its a file sending headers, that is. Any other files, its okay where you put them. i.e
<hr noshade color="black" size="1">
<?php include('file.php'); /*This file sends headers*/ ?>

That will not work. This will
<?php include('file.php'); /*this file sends headers*/ ?>
<hr noshade color="black" size="1">

that will work.

Hope this helps.

11-27-2003, 04:07 PM
You can include files where ever you want to...

If the included file has something like a session, cookie or header, it needs to be before anything is outputted to the browser. This could be white space, or html.

11-28-2003, 12:41 PM
Just curious, what will happen if I don't send the header before the html?

11-28-2003, 02:36 PM
Then you'd get the error:

warning cannot modify header .header already sent.. etc