1

I am very confused, I recently just switched from a localserver (Wamp) to a live server (DreamHost - Shared).

Now, my localserver works perfectly, yet on the live server it is raising the Cannot modify header information. That is odd because there is nothing happening there! Is there any thing I am missing?

<!DOCTYPE html>
<html>
<head>
    <?php include("/home/postinowner/postin.me/includes/head.php");?>
    <title> Your Words, Your Thoughts, So Get POSTIN'</title>
    <link type="text/css" rel="stylesheet" href="css/style.home.php.css"/>
</head>
<body>

    <div id="wrapper" class="container">
<?php

//Grabbing the database connection
require("/home/postinowner/postin.me/db_connection.php");

//Starts the session
session_start();

//Grabs the user class
require("/home/postinowner/postin.me/classes.php");

//Grabs all of the categories
require("/home/postinowner/postin.me/allcategories.php");

//Grabs the header
include("/home/postinowner/postin.me/includes/header.php");

?>

And then the head.php file:

<html lang="en-US">

<link rel="icon" type="image/png" href="http://localhost/postin'/images/favicon.ico?v=2">

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php mb_internal_encoding("UTF-8"); ?>

<link type="text/css" rel="stylesheet" href="http://localhost/postin'/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="http://localhost/postin'/css/bootstrap-theme.min.css">
<link type="text/css" rel="stylesheet" href="http://localhost/postin'/css/style.css"/>
<link type="text/css" rel="stylesheet" href="http://localhost/postin'/css/style.adboxs.css"/>

<style type="text/css">
<!--
    body {
        margin: 0px;
    }
-->
</style>
<style type="text/css">
    a:hover {color: orange;}     /* mouse over link */
    a:active {color: orange;}    /* selected link */
</style>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script>
<script src="js/bootstrap.min.js"> </script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<script type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>

P.S., I would NOT like to suppress the error.

Michael Jones
  • 2,222
  • 18
  • 32

1 Answers1

4

Your session_start() command should always be at the top of every file. Also, if you have any header functions in your code, then any and all echo commands should follow after it, and not before it.

Therefore, for example :-

<?php
if(1==1)
{
header('Locatio:something.php');//should be immediately after the `if` start braces.
echo "something here";
}
?>

Now, something which is wrong :-

<?php
if(1==1)
{
echo "something here";
header('Locatio:something.php');//should be immediately after the `if` start braces.
}
?>

Now the above code ^^ will through headers already sent error.

?>

<?php
session_start();
require("/home/postinowner/postin.me/db_connection.php");
?>
<!DOCTYPE html>
<html>
<head>
    <?php include("/home/postinowner/postin.me/includes/head.php");?>
    <title> Your Words, Your Thoughts, So Get POSTIN'</title>
    <link type="text/css" rel="stylesheet" href="css/style.home.php.css"/>
</head>
<body>

    <div id="wrapper" class="container">
<?php

//Grabs the user class
require("/home/postinowner/postin.me/classes.php");

//Grabs all of the categories
require("/home/postinowner/postin.me/allcategories.php");

//Grabs the header
include("/home/postinowner/postin.me/includes/header.php");

?>

?>
Akshay
  • 2,244
  • 3
  • 15
  • 34