저는 한 페이지에서 다른 페이지로 리디렉션하려고하는 PHP 프로젝트에서 헤더 (위치 : something.php)를 사용하고 있습니다. 그것은 로컬 컴퓨터에서 벌금을 일하고 있지만 서버에 업로드 할 때, 다음과 같은 오류가 발생합니다PHP에서 헤더 오류 정보
Warning: Cannot modify header information - headers already sent by (output started at /homepages/4/d404449574/htdocs/yellowandred_in/newTest/editHome.php:15) in /homepages/4/d404449574/htdocs/yellowandred_in/newTest/editHome.php on line 43
이미
include
,
include_once
,
require
및
require_once
으로 시도했지만이 같은 다른 오류를주고
:
Cannot redeclare logged_in() (previously declared in C:\wamp\www\ynrNewVersion-1\editHome.php:3) in C:\wamp\www\ynrNewVersion-1\adminIndex.php on line 5
내 코드
<?php
session_start();
function logged_in() {
return isset($_SESSION['username']);
}
function confirm_logged_in() {
if (!logged_in()) {
include "error404.php";
exit;
}
}
confirm_logged_in();
require_once("connection.php");
$query="select * from home";
$homeInfo = mysql_query($query, $connection);
$result = mysql_fetch_array($homeInfo);
$content = $result['content'];
$rssFeeds = $result['rssFeeds'];
$message = "";
if(isset($_POST['submit'])){
$content = $_POST['content'];
$rssFeeds = $_POST['rssFeeds'];
if($content == "" || $rssFeeds == ""){
$message = "Please enter into all the fields";
} else {
$query = "UPDATE home SET content='$content',rssFeeds='$rssFeeds' WHERE id=1 LIMIT 1";
$result = mysql_query($query,$connection);
if(!$result){
echo "error".mysql_error();
}
if ($result == 1) {
header("Location:adminIndex.php");
} else {
$message = "Error Occurred";
}
}
}
if(isset($_POST['cancel'])){
header("Location:adminIndex.php");
}
?>
. : 위의 에코 때문일 수 있습니다. 헤더가 작동하지 않고 오류가 발생했습니다. – sephoy08
문제는 헤더()를 설정하기 전에 내용을 에코하기 시작한 것입니다. 언급 된대로 @shatru로 ob_start하거나 헤더() 호출보다 먼저 텍스트를 에코하지 않도록 코드를 다시 조정하십시오. – Scuzzy