PHP Header already sent error

Bonjour,
j'ai ecrit ce code mais ca donne toujours la meme erreur ...
"Cannot modify header information - headers already sent by"
....
<html>
<head>
<title> hello</title>
</head>
<table cellspacing="3" cellpadding="2" border="rules">
<caption>titre</caption>
<colgroup>
<col style="color : darkgreen">
<col style="color : gray">
<col style="color : gold">
</colgroup>
<thead>
<tr>
<th>titre1</th>
<th>titre2</th>
</tr>
</thead>
<tbody>
<?php
include ("connexion.php");
$req = "SELECT img_id, img_type, img_blob FROM images ORDER by img_id";
$ret = mysql_query ($req) or die (mysql_error ());
while ($col = mysql_fetch_row ($ret))
{
if ( !$col[0] )
{
echo "Id d'image inconnu";
}
else
{
?>
<tr>
<td>
<?php
echo $col[0];
?>
</td>
<td>
<?php
ob_start();
header('Content-type: '.$col[1]);
ob_end_flush();
echo $col[2];
?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</html>
....

merci bien de m'aider à resoudre ce probleme...
Configuration: Windows XP
Firefox 2.0.0.7

6 réponses

  1. salut,

    Il faut essayer de placer le header le plus haut possible dans ton code, si tu ne peux pas :

    commence par enlever echo "Id d'image inconnu";

    Il n'aime pas trop les echo...

    plus d'info ici

    php headers already sent by
    0
    1. j'ai supprimé l'echo, mais le meme probleme persiste .. :S
      0
      1. tout les écho ??
        0
    2. oui tous les echos, sauf le echo $col[2] qui vient apres le header .. :S
      0
      1. fait ce que tu dis le lien

        et essaye de déplacer ce header

        Il n'y a pas 50 moyens
        0
    3. Bonjour,
      mais le header(pageX)? REDIRIGE,

      REAFFICHE VERS LA PAGE SOUHAITEE PAGEX.php, NON?

      donc après SI ON VEUT AFFICHER DANS CETTE PAGE EN QUESTION,

      comment gère t-on se problème, alors si on peut pas faire afficher depuis ce script-ci?

      Il faut traiter et appliquer le ou les opérations que l'on veut faire

      dans le script de la PAGE EN QUESTION,

      PAGE X.php ?

      N'EST CE PAS?

      MAIS JE NE COMPRENDS PAS TROP CE QUE FAIT :
      header('Content-type: '.$col[1]);

      CETTE LIGNE AFFICHE DANS LA PAGE EN QUESTION, COL1 A LA SUITE DU

      SINON EN FAISANT UN TRUC COMME CA, PEUT ETRE QUE CELA VA MARCHER :

      <?php
      I<-0
      POUR TOUT I ALLANT DE 0 à N :
      TANT QUE ( $col[i] )
      {
      ob_start();
      header('Content-type: '.$col[I]);
      ob_end_flush();
      echo $col[I++];
      ?>

      }

      OUI MAIS EST-CE QUE AUSSI LE CODE DU DEBUT:

      <html> 
      <head> 
      <title> hello</title> 
      </head> 
      <table cellspacing="3" cellpadding="2" border="rules"> 
      <caption>titre</caption> 
      <colgroup> 
      <col style="color : darkgreen"> 
      <col style="color : gray"> 
      <col style="color : gold"> 
      </colgroup> 
      <thead> 
      <tr> 
      <th>titre1</th> 
      <th>titre2</th> 
      </tr> 
      </thead> 
      <tbody> 
      


      N'ENVOIE PAS D ENTETE, NE REMPLI PAS LES ENTETE HTTP,
      et de ce fait la, il n'y aurait plus de place dans la memoire TAMBON du ZBUFFER
      DES VARIABLES ASSIGNEES et qui passent PAR LE BIAIS DE HTTP?

      DANS CE CAS LA , LE HEADER EST DE TROP ET

      CA FAIT UN MESSAGE D'ERREUR DU GENRE:

      "Cannot modify header information - headers already sent by"

      PARCE QUE LES VARIABLES SONT TROP PLEINES ET DU COUP LES HEADERS NE PASSENT PAS DU TOUT!!!

      JE ME TROMPE?

      G LE MEM GENRE DE PROBLEME AVEC LES SESSIONS AUSSI,
      et un header dans un site web et

      dans un autre fait en CSS, et PHP mais sans session pour le moment celui-ci!

      VOILA!!
      EST CE QUELQU'UN POURRAIT NOUS ECLAIRER(----)?
      0
      1. PERSONNE NE REPONDS DONC ?DOMMAGE!
        0
        1. Tu pose une kestion ? ou tu donne une réponse je ne comprend rien.

          tout est marqué dans le lien que j'ai donné apres c'est du cas par cas

          A+
          0