简体   繁体   中英

Getting “headers already sent” with Facebook PHP api

I keep getting a warning when i try and load my page...

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/blazecra/public_html/matt/header.php:23) in /home/blazecra/public_html/matt/facebook/facebook.php on line 37

Here is my header.php file

<?php
echo '<html>
<head>
    <title>MyGag - The Home of Gagging!</title>
    <link rel="stylesheet" href="style.css" type="text/css" />

</head>
<body>

    <img src="img/nav.png" height="50" width="1000">

<div id="logo">
    <a href="index.php"><img src="img/logo.png" height="50" width="150"></a>
</div>

';
?>

And on line 37 of the facebook php just has

session_start();

Any ideas why this is happening?

Ok so its saying that there is output somewhere in this header.php i know im echo ing but thats only html.

How do i not return anything if you understand me?

You cannot do session_start after you've allready sent output.

Like the error says: it can not send a cookie, because there was allready a header sent. Whenever you start to send data, a header must (and will) be sent first.

Make sure no output is sent to the user before yo you call that function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM