Click to See Complete Forum and Search --> : header PHP - HTML


Anon
05-01-2001, 12:39 PM
dear PHP Builder
hai.. my name nicky, now i learn php by my self so i have a little confuse in function header in php
i have one case like this :
in my index.php i have the sintax
----------- index.php -----------
include ("banner.html");
header (Location : $relative/view.php);
----------- banner.html ----------

<head>
<script language=javascript>
awmImageNames0=Array('awmData/dot.gif');
awmImages0=new Array();
*** the program i write in here is not complete ***
</script>
</head>
<body>
this is my page
</body>

----------------------------------
the program i make just like that, but when i run the program, i mean the php have a error like this "Warning: Cannot add header information - headers already sent by (output started at menu.php:5) in C:\HTTPD\HTDOCS\cart\index1.php on line 40"
i want to ask some question, how make the program can run without any error like i write upstair ?
how make both header i can use in my program
please tell me soon, thanks...

brandonschnell
05-01-2001, 01:01 PM
the header() function sends the user to another web page. why show a header() if you intend to show the user a web page?

remove the line:
include ("banner.html");
because header() must be called before anything is sent to the user

Anon
03-05-2002, 05:37 PM
Remember that header() must be called before any actual output is sent, either by normal HTML tags blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.


<?php require("user_logging.inc") ?>


<?php header ("Content-type: audio/x-pn-realaudio"); ?>
// Broken, Note the blank lines above



Note: In PHP 4, you can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files.