2013-01-05 90 views
-1

Possible Duplicate:
Headers already sent by PHP
Reference - What does this error mean in PHP?錯誤:頭已經發出已

<?php 
include 'connect.php'; 
include 'header.php'; 
?>  
<p>Mahtava is an organization dedicated to providing great services and web projects to people for free. We are passionate about the web and making it a better place for its citizens to live in. We have a strong emphasis on the user experience in whatever we do, and are focussed on keeping things the best for our users. Many of our projects are open source, and we always are inviting new developers to help with them or to develop projects of their own with us.</p> 
<?php 
include 'footer.php'; 
?> 

什麼是錯的,上面的代碼?它不斷給我

'Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/u599980382/public_html/newsite/index.php:1) in /home/u599980382/public_html/newsite/connect.php on line 2'.

它不具有幾乎相同的確切的代碼做任何其他的網頁,甚至沒有一個頁面(只有內容是不同的);它只在索引上做到這一點。預先感謝您提供的任何幫助。

+2

最有可能的東西' session_start()'正在向瀏覽器發送輸出。如果你爲你的腳本提供代碼,這主要是'session_start()'代碼和之前的任何代碼。 – PhearOfRayne

+0

你的代碼沒問題。這可能是connect.php或header.php的錯誤。 我認爲你的這段代碼是可以的。我嘗試使用我的頁眉,頁腳和連接文件的代碼。那麼它的工作。 :) – Nytram

+0

這可能是'session_start()'之前的任何輸出引起的,即使在你的php標籤之前有一個空格 - ' - ><?php ...'。 – Sean

回答

0

使用的頭功能頭尚未發出 您可以通過 headers_sent

// If no headers are sent, send one 
if (!headers_sent()) { 
...... 
} 

檢查它,你可以更改您的代碼這種情況下:之前

<?php 
include 'header.php'; 
include 'connect.php'; 
include 'content.php'; 
?>