header(); in php not working

Problems with the Windows version of XAMPP, questions, comments, and anything related.

header(); in php not working

Postby admindell » 21. July 2008 22:36

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!
I am creating a web admin panel for windoes xampp!

its called xDPanel.
the home page i have created can be found here. and please note that it is still under construction!
User avatar
admindell
 
Posts: 28
Joined: 28. May 2008 16:35

Postby Wiedmann » 21. July 2008 22:41

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.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby admindell » 21. July 2008 22:43

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)
I am creating a web admin panel for windoes xampp!

its called xDPanel.
the home page i have created can be found here. and please note that it is still under construction!
User avatar
admindell
 
Posts: 28
Joined: 28. May 2008 16:35

Postby Wiedmann » 21. July 2008 23:05

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.)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby admindell » 22. July 2008 02:34

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?
I am creating a web admin panel for windoes xampp!

its called xDPanel.
the home page i have created can be found here. and please note that it is still under construction!
User avatar
admindell
 
Posts: 28
Joined: 28. May 2008 16:35

Re: header(); in php not working

Postby Dave_L » 22. July 2008 10:57

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.
User avatar
Dave_L
 
Posts: 212
Joined: 23. October 2004 00:43

Postby Wiedmann » 22. July 2008 13:35

how do i do it with notepad?

AFAIK you can't save UTF-8 files without BOM in notepad.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby admindell » 23. July 2008 01:31

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
I am creating a web admin panel for windoes xampp!

its called xDPanel.
the home page i have created can be found here. and please note that it is still under construction!
User avatar
admindell
 
Posts: 28
Joined: 28. May 2008 16:35

Postby sckoh » 24. July 2008 04:39

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.
Image
User avatar
sckoh
 
Posts: 67
Joined: 01. March 2005 02:16
Location: Washington DC


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 80 guests