PHP Header already sent error
tino1984
Messages postés
3
Date d'inscription
Statut
Membre
Dernière intervention
-
Utilisateur anonyme -
Utilisateur anonyme -
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...
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:
- PHP Header already sent error
- Easy php - Télécharger - Divers Web & Internet
- Your browser sent a request that this server could not understand. size of a request header field exceeds server limit. ✓ - Forum Réseaux sociaux
- Gpt header corruption ✓ - Forum Windows 10
- Fan error lenovo - Forum Refroidissement
- Expert php pinterest - Télécharger - Langages
6 réponses
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
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
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:
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(----)?
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(----)?
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question