Page 1 of 1

header(); in php not working

PostPosted: 21. July 2008 22:36
by admindell
even when i create a file like this:

<?php
header("Location: index4.php");
?>

it gives a error

Warning: Cannot modify header information - headers already sent by (output started at C:\web_server\htdocs\index.php:1)

i didnt ues the /xampp/ dir, i used web_server

could that be the problem?

i need help!

PostPosted: 21. July 2008 22:41
by Wiedmann
You PHP script is encoded in UTF-8 with BOM (the BOM is the problem).

BTW:
You must use an absolute URI in "Location", not only a filename.

PostPosted: 21. July 2008 22:43
by admindell
Wiedmann wrote:You PHP script is encoded in UTF-8 with BOM (the BOM is the problem).

BTW:
You must use an absolute URI in "Location", not only a filename.


so how do i remove BOM???

im new to this, i know things, but i dont know things, please explain like your talking to a 14 year old (hehe well you are)

PostPosted: 21. July 2008 23:05
by Wiedmann
so how do i remove BOM???

Read the manual of your editor how to save UTF-8 files without BOM.

(Or don't use UTF-8 if you don't need it.)

PostPosted: 22. July 2008 02:34
by admindell
Wiedmann wrote:
so how do i remove BOM???

Read the manual of your editor how to save UTF-8 files without BOM.

(Or don't use UTF-8 if you don't need it.)


ok, im useing notepad....

how do i do it with notepad?

Re: header(); in php not working

PostPosted: 22. July 2008 10:57
by Dave_L
admindell wrote:Warning: Cannot modify header information - headers already sent by (output started at C:\web_server\htdocs\index.php:1)


Check that you don't have any text, including whitespace (spaces, line feeds, carriage returns, tabs) outside of the <?php ... ?> delimiters.

PostPosted: 22. July 2008 13:35
by Wiedmann
how do i do it with notepad?

AFAIK you can't save UTF-8 files without BOM in notepad.

PostPosted: 23. July 2008 01:31
by admindell
Wiedmann wrote:
how do i do it with notepad?

AFAIK you can't save UTF-8 files without BOM in notepad.


i googled, i know that now, i fixed the problem

PostPosted: 24. July 2008 04:39
by sckoh
headers already sent by ... is a typical error in php.
It occures from blank space before <?php or after ?>.
Therefor, you need to use proper text editor(Not Notepad).

Else, you saved php file with UTF-8 with BOM.
So, you have to save it with UTF-8 without Byte Order Mark.