开发者

Cannot modify header information - headers already sent by ... Error [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

PHP error: Cannot modify header information – headers already sent

Hi I am getting this error e开发者_如何学Goven thou I am using exactly the same file for other projects and it's working fine. This project is set after implementation by FB new API and all the changes after the end of September does this fact could be an issue?

MY FILE:

<?php echo '<?xml version="1.0" encoding="UTF-8"?>'."\n"; ?>
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Thu, 1 Jan 1970 00:00:00 GMT");
include_once 'config.php';
$con = mysql_connect($db_ip,$db_user,$db_pass);
.
.
.
.
while ($row = mysql_fetch_assoc($result)) {
?>
    <id>
    <image>http://mywebsite/root/xxx-game-fb/proxy.php?url=<?php echo urlencode("http://graph.facebook.com/".$row['fbid']."/picture?type=square"); ?></image>
    <place><?php echo $position; ?></place>
    <name><?php echo $row['name']; ?></name>
    <score><?php echo $row['score']; ?></score>
</id>
<?php
$position++;
}
?>
</users>

I use this as an input to flash AS3 game. It creates a table with users and sets them in order. Flash throws an error as well in the function that pulls this xml file. Does any one knows what could be a problem here? Please help.


Didn't read the docs about header and no information can be output before a call to that method, huh?

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

Either use header first, or use some form of output buffering if it can't be avoided.


Your first 5 lines of your file should become:

<?php
  header("Cache-Control: no-cache, must-revalidate");
  header("Expires: Thu, 1 Jan 1970 00:00:00 GMT");
  echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Note that header() is now called before anything is echo'd/output.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜