Possible Duplicate:
Headers already sent by PHP不能更改頭信息
錯誤:
Warning: Cannot modify header information - headers already sent by (output started at functions.php:37) in functions.php on line 207
add.php
<?php include('functions.php'); ?>
<?php global_header("Add"); ?>
<?php page_navigation(); ?>
<?php
// If no form has been submitted, present form
if (empty($_POST))
{
add_form();
}
// if a form has been submitted
else
{
// if form_validity() == 1, proceed to connect
if (form_validity() == 1)
{
// connect to mysql + database
connect();
// get values from form, insert into database
$saleItemCheck = isset($_POST['saleItem'])?"y":"n";
$discItemCheck = isset($_POST['discountedItem'])?"y":"n";
$sql=("INSERT INTO inventory (name, manufac, model, descrip, onhand, reorder, cost, price, sale, discont, deleted)
VALUES ('$_POST[itemName]', '$_POST[manufacturer]', '$_POST[model]', '$_POST[description]', '$_POST[numberOnHand]',
'$_POST[reorderLevel]', '$_POST[cost]','$_POST[sellingPrice]',
'$saleItemCheck', '$discItemCheck', 'n')");
// if the query doesn't work, display error message
if (!(mysql_query($sql))) { die ("could not query: " . mysql_error()); }
add_form();
redirect("view.php");
}
else
{
// if form is not valid (form_validity returns 0), display error messages
add_form();
}
}
?>
<?php page_footer(); ?>
我重定向功能
<?php
function redirect($page)
{
header('Location:'.$page); <------------------------------------ line 207
}?>
頭功能
<?php
function global_header($page_title)
{
$content = '<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DIMAS OLYMPIC WEIGHTLIFTING EQUIPMENT - ' . $page_title . '</title>
<meta name="description" content="BTI320 Assignment 1">
<meta name="author" content="Marcel Olszewski - 078-681-103">
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="container">
<div><img src="logo.png" id="logo" alt="I (Marcel Olszewski) created this in photoshop" /></div>';
echo $content; <------------------- LINE 37
}
?>
它工作過,現在不行,不太清楚爲什麼。
完成後空格它好工作之前,不知道我哪裏錯了。 – eveo
正如我所說的,它可能是你現在得到的錯誤,以前沒有出現。另外,如果你的PHP代碼的編碼發生了變化,一個BOM字符可能已經預先考慮到你的代碼,是一種不由自主的,但非常實際產出你把你的頭前。 –
使用記事本++擺脫BOM字符,仍然無法正常工作。 – eveo