开发者

Warning: Cannot modify header information. Can't find error [duplicate]

This question already 开发者_运维知识库has answers here: How to fix "Headers already sent" error in PHP (11 answers) Closed 9 years ago.

I'm using a login-script and on my developmachine it worked perfectly but when I moved it to my webhost it stopped working.

The code can be viewed here: http://beta.yapaste.com/fm

The error I get when I login is

Warning: Cannot modify header information - headers already sent by (output started at /*/*/*/*/*/*/login.php:10) in /*/*/*/*/*/*/inc/login.php on line 43

But I can't find the error.

Thanks for answers, Victor.

Edit: Found the error, I included the file that I've got on yapaste in another file so the php-code wasent first.


On line 10 of login.php something is sent to the browser (white space between ?> and <?PHP tags count), at which point headers must be sent to. This triggers a warning when you try to then add more headers after this, on line 43.

You need to have a look at line 10 and prevent the output being sent, or use output buffering - your previous host could have had this on by default which might explain why it no longer works...


use ob_start(); at entry of your script to start buffering, but as Simon said, propably there is some white space wich is sended to browser befor you try to change headers.

Remeber, that you can omit ending php tag if you don't have any output code after, That will secure you from white spaces at end of file.

Also check for format of your source files - if they are encoded in UTF-8 with BOM, there are some starting characters that could be not shown in editor at beginning of the file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜