PHP Header already sent error

Fermé
tino1984 Messages postés 3 Date d'inscription jeudi 18 octobre 2007 Statut Membre Dernière intervention 18 octobre 2007 - 18 oct. 2007 à 12:39
 Utilisateur anonyme - 18 oct. 2007 à 18:05
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...
A voir également:

6 réponses

Utilisateur anonyme
18 oct. 2007 à 12:43
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
tino1984 Messages postés 3 Date d'inscription jeudi 18 octobre 2007 Statut Membre Dernière intervention 18 octobre 2007
18 oct. 2007 à 12:49
j'ai supprimé l'echo, mais le meme probleme persiste .. :S
0
Utilisateur anonyme
18 oct. 2007 à 13:16
tout les écho ??
0
tino1984 Messages postés 3 Date d'inscription jeudi 18 octobre 2007 Statut Membre Dernière intervention 18 octobre 2007
18 oct. 2007 à 13:25
oui tous les echos, sauf le echo $col[2] qui vient apres le header .. :S
0
Utilisateur anonyme
18 oct. 2007 à 13:44
fait ce que tu dis le lien

et essaye de déplacer ce header

Il n'y a pas 50 moyens
0
davidmickael Messages postés 98 Date d'inscription jeudi 17 mai 2007 Statut Membre Dernière intervention 23 janvier 2009 2
18 oct. 2007 à 16:56
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

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
davidmickael Messages postés 98 Date d'inscription jeudi 17 mai 2007 Statut Membre Dernière intervention 23 janvier 2009 2
18 oct. 2007 à 17:42
PERSONNE NE REPONDS DONC ?DOMMAGE!
0
Utilisateur anonyme
18 oct. 2007 à 18:05
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