-2

getting this error... Normally associate it with a space / output before the php / headers sent but cant get to the bottom of this one.

So the error is:

Warning: Cannot modify header information - headers already sent by 
(output started at
/Applications/MAMP/htdocs/website/index.php:11) in 
/Applications/MAMP/htdocs/website/process/checkautologin.php on line 65

Warning: Cannot modify header information - headers already sent by 
(output started at /Applications/MAMP/htdocs/website/index.php:11) 
in /Applications/MAMP/htdocs/website/process/checkautologin.php on line 120

Index PHP looks like this at the top:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>BuildSanctuary</title>
    <?php
    require 'init.php';
    ?>

Line 11 is the opening php tag.

Line 65 in check auto login is:

setcookie ("cookie",0,time() -3600,'/');

And its surrounding code is:

// 'login' the user by setting the usual sessions
$_SESSION['user'] = $usernameuser;
$_SESSION['userid'] = $userid;
$_SESSION['logged'] = "1";
setcookie("cookie",0,time() -3600,'/');

// query the database to try and find a mactching row:
$query = " DELETE FROM `remember_me` WHERE `token` = :token "; 

// Create bound values
$query_params = array( 
  ':token' => $row['token'],
); 

This is the bottom part:

// set new cookie
setcookie ("cookie",$new_cookie_val,time() + (10 * 365 * 24 * 60 * 60),'/');
} 
catch(PDOException $ex) 
{   <-- this is line 120.           
}

Any ideas?

Lovelock
  • 7,689
  • 19
  • 86
  • 186

1 Answers1

1

Incorrect:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>BuildSanctuary</title>
    <?php
    require 'init.php';
    ?>

Correct:

<?php
require 'init.php';
?>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>BuildSanctuary</title>
gpupo
  • 942
  • 9
  • 16