Page 1 sur 1

Header may not contain more than a single heade

Posté : 28 déc. 2012, 09:01
par musatge
Bonjour
J'ai le message d'erreur suivant:
Warning: Header may not contain more than a single header, new line detected. in C:\wamp\www\mvc_blog\mycontroller.php on line 6
lors de l'éxécution du script mycontroller.php:
<?php
	require ('mymodel.php');
	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		insert_comment($_POST);
		header("HTTP/1.1 301 Moved Permanently");
		header("location: {$_SERVER['SCRIPT_NAME']}?news_id={$_POST['news_id']}");
		exit;
	} else {
		$news = obtenir_articles($_GET['news_id']);
		$comments = obtenir_etiquettes($_GET['news_id']);
		require ('myview.php');
	}
?>
Merci pour votre aide

Re: Header may not contain more than a single heade

Posté : 28 déc. 2012, 13:45
par dix2
salut,

avec ceci, tu obtiens quoi :
<?php
        require ('mymodel.php');
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                insert_comment($_POST);
                //header("HTTP/1.1 301 Moved Permanently");
                //header("location: {$_SERVER['SCRIPT_NAME']}?news_id={$_POST['news_id']}");
                print_r("location: {$_SERVER['SCRIPT_NAME']}?news_id={$_POST['news_id']}");
                exit;
        } else {
                $news = obtenir_articles($_GET['news_id']);
                $comments = obtenir_etiquettes($_GET['news_id']);
                require ('myview.php');
        }
?>

Re: Header may not contain more than a single heade

Posté : 28 déc. 2012, 19:07
par musatge
Merci dix2,
mais en fait l'erreur venait $_POST['news_id'] qui restait vide