0

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?

Matt Williams
  • 79
  • 1
  • 8
  • possible duplicate of [Headers already sent by PHP](http://stackoverflow.com/questions/8028957/headers-already-sent-by-php) – mario Feb 12 '12 at 21:22
  • ANY output, that includes the html. –  Feb 12 '12 at 21:29

1 Answers1

3

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.

Nanne
  • 64,065
  • 16
  • 119
  • 163
  • Okay where am i outputting to the user in this file. I cant see it – Matt Williams Feb 12 '12 at 21:26
  • Well, You could be doing anything? How should I know, you've not given me the complete code... But my guess is: header.php? It does say "echo" in there, doesn't it? – Nanne Feb 12 '12 at 21:27