-2

I have just switching hosting. Everything used to work fine. I have now copied all the files onto the new ftp server, set up the database, etc. however I get these messages on every page:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/pesterlo/public_html/core/init.inc.php:15) in /home/pesterlo/public_html/core/init.inc.php on line 23

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pesterlo/public_html/core/init.inc.php:15) in /home/pesterlo/public_html/core/init.inc.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /home/pesterlo/public_html/core/init.inc.php:15) in /home/pesterlo/public_html/core/init.inc.php on line 36

Here is the init.inc.php file (-database connection):

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="ext/css/main.css" />
<title>PesterLog</title>
 <link rel="icon" type="image/x-icon" href="favicon.ico" />
  <link rel="shortcut icon" href="images/favicon.ico" />
    <link rel="apple-touch-icon" href="apple-touch-icon.png" />
    <link rel="apple-touch-icon" sizes="72x72" href="apple-touch-icon-72x72.png" />
    <link rel="apple-touch-icon" sizes="114x114" href="apple-touch-icon-114x114.png" />
    <script type="text/javascript" src="http://pesterlog.tk/core/pages/js/jquery_1.5.2.js"></script>
<script type="text/javascript" src="http://pesterlog.tk/core/pages/js/loaded_contents.js"></script>
    </head>

<?php
date_default_timezone_set('Europe/London');
$core_path = dirname(__FILE__);
if (empty($_GET['page']) || in_array("{$_GET['page']}.page.inc.php", scandir("{$core_path}/pages")) == false){
header('HTTP/1.1 404 Not Found');
header('Location: index.php?page=inbox');
die();
}
session_start();
echo mysql_error();

//connects to database

include("{$core_path}/inc/user.inc.php");
include("{$core_path}/inc/private_message.inc.php");

if (isset($_POST['user_name'], $_POST['user_password'])){
    if (($user_id = validate_credentials($_POST['user_name'], $_POST['user_password'])) !== false){
        $_SESSION['user_id'] = $user_id;

        header('Location: index.php?page=inbox');

        die();
    }
}

if (empty($_SESSION['user_id']) && $_GET['page'] !== 'login'){
    header('http/1.1 403 Forbidden');
    header('location: index.php?page=login');

    die();
}

$include_file = "{$core_path}/pages/{$_GET['page']}.page.inc.php";

?>

Please help me.

Thank you in advance

user3315726
  • 13
  • 1
  • 5
  • Put your PHP code on top of your HTML, remove the `echo mysql_error()` – AyB Feb 25 '14 at 06:45
  • When I do that, all my styling is lost and I just have a white page with Warning: Cannot modify header information - headers already sent by (output started at /home/pesterlo/public_html/core/inc/private_message.inc.php:1) in /home/pesterlo/public_html/core/init.inc.php on line 21 – user3315726 Feb 25 '14 at 06:47
  • @ICanHasCheezburger Thanks, that removes the errors from the login form page, but when you log in, they still come – user3315726 Feb 25 '14 at 06:49
  • Did you remove all the `die()`? – AyB Feb 25 '14 at 06:51
  • @ICanHasCheezburger yes – user3315726 Feb 25 '14 at 06:52

1 Answers1

0

Remove mysql_error(). use ob_start(); before date_default_timezone_set();

Ananth
  • 1,520
  • 3
  • 15
  • 28
  • Thank you, that works but I get this message when it goes to the inbox: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies. – user3315726 Feb 25 '14 at 06:51
  • i think , you are redirecting to same page. – Ananth Feb 25 '14 at 06:55
  • i mean, you have also included the init.inc.php in the index.php page so only this error occurs – Ananth Feb 25 '14 at 06:56
  • so how would I fix these errors? – user3315726 Feb 25 '14 at 07:10