Andy: Senden von Headern nicht möglich :-(

hi!

ich poste gleich mal etwas quellcode:

<?//-*- C++ -*-
/*   ********************************************************************   **
**   Copyright (C) 1995-2000 Michael Oertel                                 **
**   Copyright (C) 2000-     PHPOpenChat Development Team                   **
**   http://www.ortelius.de/phpopenchat/                                    **
**                                                                          **
**   This program is free software. You can redistribute it and/or modify   **
**   it under the terms of the PHPOpenChat License Version 1.0              **
**                                                                          **
**   This program is distributed in the hope that it will be useful,        **
**   but WITHOUT ANY WARRANTY, without even the implied warranty of         **
**   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                   **
**                                                                          **
**   You should have received a copy of the PHPOpenChat License             **
**   along with this program.                                               **
**   ********************************************************************   */

/*
 * Include some default values
 */
include("defaults_inc.php");

/**
 * Check for access permissions of this page
 *
 * compare the given and the calculated checksum,
 * if they don't match the user has no permissions
 * and the script ends by printing a status header of 204
 * (no content change by client browser)
 */
if(!check_permissions($nick,$pruef)){
  //the user has no access permission for this page
  header("Status: 204 OK");//browser don't refresh his content
  exit;
}

/*
 * Open a database connection
 * The following include returns a database handle
 */
include ("connect_db_inc.php");
$db_handle=connect_db($DATABASEHOST,$DATABASEUSER,$DATABASEPASSWD);
if(!$db_handle){
  exit;
}
?>
<HTML>
<HEAD>
<TITLE>Document1</TITLE>
<meta http-equiv="refresh" content="7; URL=<?php echo $PHP_SELF; ?>">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="style.css">
<script language="JavaScript" type="text/javascript">
<!--
function OpenUserpage(file) {
  var newWindow;
  newWindow=window.open(file,"userpage","scrollbars=yes,directories=no,width=640,height=480")
  if (newWindow != null && newWindow.opener == null)
    newWindow.opener=window
}
// -->
</script>
</HEAD>
<BODY style="background-color: #FF7200; margin: 0px;" scroll="no">

<table border="0" cellspacing="5" cellpadding="5" width="100%" bgcolor="#dddddd"><tr><td bgcolor="#888888"><table border="0" cellspacing="3" cellpadding="0" width="100%"><tr><td><span style="font-weight: bold; color: #ffffff;">Who is online?</td></tr></table></td></tr></table><br />

<table border="0" width="100%" cellspacing="5">
<tr>
<td>

<table border="0" cellspacing="3" cellpadding="3">

<?
  $chatterinroom = mysql_query("SELECT Nick, Zeit FROM chat ORDER BY Nick");
  while($nickrow = mysql_fetch_object($chatterinroom)){
   $shownick=$nickrow->Nick;
   $showtime=$nickrow->Zeit;
   $nick_color = @mysql_result(mysql_query("SELECT color FROM chat_data WHERE Nick='$shownick'",$db_handle),0,"color");
   if($nick_color==''){$nick_color = '#e1e1e1';}

$jetzt = time();
$inaktiv = $jetzt-$showtime;

if ($inaktiv <= "10")
{

if($ENABLE_USERPAGES)
 {
 // Abfrage des Geschlechts
 $result_userpage=mysql_query("SELECT * FROM chat_userpages WHERE Nick='$shownick'",$db_handle);
 $userpagedata=mysql_fetch_array($result_userpage);

echo '<tr><td align="center"><img src="images/gender_'.$userpagedata[Gender].'.gif" /></td><td><a class="online" href="javascript:OpenUserpage('userpage.php?'.session_name().'='.session_id().'&user='.urlencode($shownick).'')">';
 echo str_replace(" "," ",$shownick);
 echo '</a>';
     echo '<br />'.$inaktiv;
 echo '</td></tr>';
 }
 else
 {
 echo '.str_replace(" "," ",$shownick).';
 }

}
else if ($inaktiv > "10" && $shownick==$nick)
{
// $result=mysql_query("DELETE FROM chat WHERE Zeit<(UNIX_TIMESTAMP()-(10))",$db_handle);
header("Location: help_de.html");
}

else
{
echo "";
// $result=mysql_query("DELETE FROM chat WHERE Zeit<(UNIX_TIMESTAMP()-(10))",$db_handle);
};

}

mysql_close($db_handle);
?>

</table>

</td>
</tr>
</table>
</BODY>
</HTML>

die Zeile

header("Location: help_de.html");

ist der entscheidende Ansatz. Sobald der Fall eintritt, wo er auf diese Seite wechseln soll, kommt nur die Fehlermeldung

Who is online?

Warning: Cannot add header information - headers already sent by (output started at c:\foxserv\www\chat\html\mainonlinelist.php:49) in c:\foxserv\www\chat\html\mainonlinelist.php on line 113

woran liegt das und was kann man da machen?

danke für eure hilfe!

  1. Hi,

    ich poste gleich mal etwas quellcode:

    beschränke es bitte auch auf "etwas". Ein komplettes Script muss nun wirklich nicht sein.

    Warning: Cannot add header information - headers already sent
    woran liegt das

    Was daran verstehst Du nicht?

    und was kann man da machen?

    Der HTTP-Header ist beendet, sowie das erste Byte des HTTP-Bodies geschrieben wird. Also: Sende die Header _vor_ dem Body.

    Siehe auch Archiv.

    Cheatah

    --
    X-Will-Answer-Email: No
  2. hi

    du kannst den header nur senden, wenn du noch KEIN!!! einziges zeichen an den browser ausgegeben hast. du kannst also beliebig viel php-code basteln, aber kei print, bzw. echo machen! sobald du 1 zeichen an den browser ausgegeben hast, ist es vorbei...

    gruss