views:

56

answers:

3

Hi All,

I'm a newbie for PHP5 and In my php page I'm getting this error when try to redirect to another page

Warning: Cannot modify header information - headers already sent by (output started at <path to my php file>:<line number>) in <path to my php file> on line <line number>

in my php file I have several includes and each one doesnt have any space before of after tag

can anyone help me

thanks in advance

cheers

sameera

A: 

This is because you must first set your headers and then add any output.

If you did not echo/print anything make sure you did not have warnings or notices (the count as output too if you have error reporting on).

As a good practice, if you can, put the header calls at the top of your script.

You could also take a look into output buffering if you need to generate output before headers.

Alin Purcaru
A: 

Maybe your php file has a unicode signature (BOM) which adds a signature at the beginning of your file.

open your php file with a plain text editor like notepad and see if there is something at the beginning of your file. if so, remove them.

rahim asgari
A: 

The problem could be an opening <? tag with some spaces just before the "<" like shown here "_<". These spaces count as output and can prevent headers from being set.

ITroubs