[PHP] Problème headers already sent by
Résolu
gautordi0101
Messages postés
20
Statut
Membre
-
gautordi0101 Messages postés 20 Statut Membre -
gautordi0101 Messages postés 20 Statut Membre -
Bonjour à tous,
J'ai un problème avec un script PHP et je ne comprends pas d'où vient l'erreur...
Voici le code d'erreur retourné par PHP :
Voici le bout du code où est située l'erreur (fichier profile.php ; lignes 4 à 28) :
Merci à tous ceux qui trouveraient une solution ;D
J'ai un problème avec un script PHP et je ne comprends pas d'où vient l'erreur...
Voici le code d'erreur retourné par PHP :
Warning: Cannot modify header information - headers already sent by (output started at F:\Server\www\PHP\site_test\v2\overall_header.php:300) in F:\Server\www\PHP\site_test\v2\profile.php on line 23
Voici le bout du code où est située l'erreur (fichier profile.php ; lignes 4 à 28) :
if(!empty($_GET["id"])) {
$get_id = htmlspecialchars($_GET["id"]);
mysql_connect("".$db_server."", "".$db_username."", "".$db_passwd."");
mysql_select_db("".$db_database."");
$query_identify = mysql_query("SELECT * FROM ".$db_tables_prefix."userdata WHERE user_id='".$get_id."'") or die ("<p>Erreur SQL générale.<br />Contactez l'administrateur du site ou du serveur.</p>");
if (mysql_num_rows($query_identify) != 1) {
header ("Location: error.php?user_unknown");
}
$db_reply = mysql_query("SELECT * FROM ".$db_tables_prefix."userdata WHERE user_name = '".$_COOKIE["".$cookie_name.""]."'") or die ("<p>Erreur SQL générale.<br />Contactez l'administrateur du site ou du serveur.</p>");
while ($data = mysql_fetch_array($db_reply))
{
$user_logged_id = $data['user_id'];
}
$db_reply2 = mysql_query("SELECT * FROM ".$db_tables_prefix."userdata WHERE user_id = '".$get_id."'") or die ("<p>Erreur SQL générale.<br />Contactez l'administrateur du site ou du serveur.</p>");
while ($data2 = mysql_fetch_array($db_reply2))
{
$user_id = $data2['user_id'];
$account_status = $data2['account_status'];
if($user_logged_id == $user_id) {
header ("Location: my_profile.php"); //ligne 23 !
}
if($account_status != 1) {
header ("Location: error.php?user_unavailable");
}
}
...
Merci à tous ceux qui trouveraient une solution ;D
A voir également:
- Cannot modify header information - headers already sent by (output started
- Information d'identification réseau - Guide
- Realtek digital output ✓ - Forum Audio
- To be filled by o.e.m - Forum Windows
- Message bounced by administrator - Forum Mail
- Photos liked by ne fonctionne plus ✓ - Forum Facebook
Si tu es en UTF-8, vérifie qu'il n'y ait pas le BOM.
<?php if (stristr($_SERVER["SCRIPT_NAME"], "my_profile.php")) { if(empty($_GET["view"])) { ?> <script type="text/javascript"> function ajax() { obj = document.getElementById("earlier_msg"); obj.innerHTML = ""; if(window.XMLHttpRequest) // FIREFOX xhr_object = new XMLHttpRequest(); else if(window.ActiveXObject) // IE xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); else return(false); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { if(xhr_object.status == 200) obj.innerHTML += "" + xhr_object.responseText; else obj.innerHTML += "Erreur — " + xhr_object.status; } }; xhr_object.open("GET", "ajax.php?query=my_profile", true); xhr_object.send(null); } </script> <?php } else { if($_GET["view"] == "other_msg") { ?> <script type="text/javascript"> function ajax() { obj = document.getElementById("earlier_msg"); obj.innerHTML = ""; if(window.XMLHttpRequest) // FIREFOX xhr_object = new XMLHttpRequest(); else if(window.ActiveXObject) // IE xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); else return(false); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { if(xhr_object.status == 200) obj.innerHTML += "" + xhr_object.responseText; else obj.innerHTML += "Erreur — " + xhr_object.status; } }; xhr_object.open("GET", "ajax.php?query=my_msg", true); xhr_object.send(null); } </script> <?php } } } if (stristr($_SERVER["SCRIPT_NAME"], "profile.php")) { if(empty($_GET["view"])) { if(isset($_GET["id"])) { $get_user_id = htmlspecialchars($_GET["id"]); ?> <script type="text/javascript"> function ajax() { obj = document.getElementById("earlier_msg"); obj.innerHTML = ""; if(window.XMLHttpRequest) // FIREFOX xhr_object = new XMLHttpRequest(); else if(window.ActiveXObject) // IE xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); else return(false); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { if(xhr_object.status == 200) obj.innerHTML += "" + xhr_object.responseText; else obj.innerHTML += "Erreur — " + xhr_object.status; } }; xhr_object.open("GET", "ajax.php?query=profile&user_id=<?php echo $get_user_id; ?>", true); xhr_object.send(null); } </script> <?php } } else { if($_GET["view"] == "other_msg") { if(isset($_GET["id"])) { $get_user_id = htmlspecialchars($_GET["id"]); ?> <script type="text/javascript"> function ajax() { obj = document.getElementById("earlier_msg"); obj.innerHTML = ""; if(window.XMLHttpRequest) // FIREFOX xhr_object = new XMLHttpRequest(); else if(window.ActiveXObject) // IE xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); else return(false); xhr_object.onreadystatechange = function() { if(xhr_object.readyState == 4) { if(xhr_object.status == 200) obj.innerHTML += "" + xhr_object.responseText; else obj.innerHTML += "Erreur — " + xhr_object.status; } }; xhr_object.open("GET", "ajax.php?query=msg&user_id=<?php echo $get_user_id; ?>", true); xhr_object.send(null); } </script> <?php } } } } ?>Parce que sinon, je ne vois pas d'autre code (ou texte, qui a besoin des variables) en dehors de <?php ... ?> ...
J'utilisais un script PHP qui analysait l'URL de la page en cours pour activer ou pas un JS...
Cela bloquait le header...
J'ai réussit à le corriger :).
Merci beaucoup à toi, avion-f16 :) !