0

I have read through the numerous posts here on SO about header errors, and been all through Google, but none of the proposed solutions seems to be what I need. I don't have extra spaces; heck, I'm not even actually sending a header(), but I'm still getting this error:

Warning: Cannot modify header information - headers already sent by (output started at header.inc.php:20)

The first 21 lines of header.inc.php are:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>LocalKarma.org - What goes around comes around!</title>
    <link rel="stylesheet" href="css/standardize.css">
    <link rel="stylesheet" href="css/styles.css">
    <link rel="stylesheet" media="only screen and (max-width: 5in),
screen and (min-width: 200px) and (max-device-width: 640px) and (orientation:portrait) and (max-width: 5in),
screen and (min-width: 600px) and (max-device-width: 1280px) and (orientation:portrait) and (max-width: 5in),
screen and (min-width: 600px) and (max-device-width: 1280px) and (orientation:portrait) and (min-width: 6in)" href="css/mobile.css">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" href="/favicon.ico" type="image/x-icon">
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700' rel='stylesheet' type='text/css'>
        <!--[if lt IE 9]>
            <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
            <script src="scripts/html5shiv-printshiv.js"></script>
        <![endif]-->
<?php
    $pageName = $_SERVER['REQUEST_URI'];

I have tried moving part of my php up before the DOCTYPE (Line 21: $pageName = $_SERVER['REQUEST_URI'];) so there would be php before the html. Nope. I tried changing all the code so that it was php output, echoing out all the html. Nope. Since this is an include file, I have looked all through the other includes that are included before this one, as well as including this one before the other ones. Nope. And… several other things that didn't work.

Any other suggestions? I assume it's something really simple and I'm just not seeing it :)

  • So... where's the `header()` line? Also, I'm assuming header.inc.php is actually included, if there is any content output anywhere in any file run before the header line this error will be raised. – Jonnix Jun 08 '15 at 22:36
  • Are you by chance starting a session? – Kevin Nagurski Jun 08 '15 at 22:43
  • @Jon Stirling: "So... where's the header() line?" That was my question, too. I was wondering if `$_SERVER['REQUEST_URI']` somehow modified the header by making a request? But then, it is line 20, the line before that, which is triggering the error. @Kevin Nagurski: Yes, the main document that this file is included in begins by starting a session. – Rod the Sun God Jun 08 '15 at 22:51
  • Well, it's your code, so I don't know how you expect us to be able to tell you. It's nothing to do with $_SERVER. Presently, if you don't know where the `header()` function is that's causing the warning, then you're going to have problems sorting the issue. – Jonnix Jun 08 '15 at 22:53
  • Well, I don't "expect" anything. I'm just looking for input. If you guys don't see anything I have missed, or have any observation about anything I don't know yet, then you are correct: I have to keep digging elsewhere. Thanks! – Rod the Sun God Jun 08 '15 at 22:56
  • that is not the *whole* error message there will be an `in .. on line ..` the important information you left out –  Jun 08 '15 at 23:07
  • 1
    Yeah, the whole message is `Warning: Cannot modify header information - headers already sent by (header.inc.php:20) in includes/client-page.inc.php on line 34`, where the second bit actually is a header that sends the user to an error page. I looked at the possible duplicate page for answers, but I will look at it again. To be honest, the problem here is that I was coding while I was sick. Let that be a lesson! – Rod the Sun God Jun 09 '15 at 00:24

0 Answers0