Headers already sent?

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Headers already sent?

    Hello.

    I just wondered if anyone has experienced this error before?

    "Warning: Cannot modify header information - headers already sent."

    Thanks for any help

    John


    John Guest

  2. Similar Questions and Discussions

    1. Please help me to set my headers and footers
      I have to use these settings for my books. Margin In Inches Book Size In Inches 5-1/2 x 8-1/2 Top/0.7 Bottom/3.2 Left/2.25 Right/2.25...
    2. Pb headers
      Hi, On my page index.php (which is the default error page of my website), i eventually show an error message which comes from the analysis of...
    3. Headers for ID CS?
      Is there a plug-in or a script for ID CS to do running phonebook style headers (like can be done in Pagemaker)? I have one job I've kept in PM...
    4. curl and sent headers
      is there any way of seeing exactly what headers cURL sent in a transfer, with PHP?
    5. [PHP] Please dirrect me -- headers ????
      Hi, Headers have nothing to do with the <head> tag, the headers are sent before the html page, ie they are not part of the html document, but...
  3. #2

    Default Re: Headers already sent?

    On Fri, 22 Oct 2004 22:34:14 -0700, A strange species called "Michael
    Vilain <vilain@spamcop.net>" wrote:
    >In article <hcojn0d4pas4fpgsg8k2fo9uvv6o7rb2bv@4ax.com>,
    > John <duki@dafiqak.com> wrote:
    >
    >> I just wondered if anyone has experienced this error before?
    >> "Warning: Cannot modify header information - headers already sent."
    >
    >Yes. It's a common mistake if you send anything to the browser then
    >send a header(). Use headers_send() to test if this is true and fix
    >your logic.
    How do I use this headers_send() to test? I am not so advanced.

    The error it says is on line 52

    This is line 52:

    header("Location: ". $MM_redirectLoginSuccess );

    It doesn't look like it is sending anything further? It is just
    registering the session variables and then redirecting.

    I put the whole php part of the page at the bottom. I had the same
    problem in my registration page but solved it by deleting whitespace.
    I tried doing the same with this file but I still have the error.

    John



    <?php
    session_start();
    // *** Validate request to login to this site.
    //session_start();
    ?>

    <?php
    // Report all PHP errors (bitwise 63 may be used in PHP 3)
    error_reporting(E_ALL);
    ?>

    <?php require_once('Connections/conn_newland.php'); ?>
    <?php
    // *** Validate request to login to this site.


    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($accesscheck)) {
    $GLOBALS['PrevUrl'] = $accesscheck;
    session_register('PrevUrl');
    }

    if (isset($_POST['username'])) {
    $loginUsername=$_POST['username'];
    $password=$_POST['pwd'];
    $MM_fldUserAuthorization = "userGroup";
    $MM_redirectLoginSuccess = "index.php";
    $MM_redirectLoginFailed = "login_failed.php";
    $MM_redirecttoReferrer = true;
    mysql_select_db($database_conn_newland, $conn_newland);

    $LoginRS__query=sprintf("SELECT username, pwd, userGroup FROM
    tbl_users WHERE username='%s' AND pwd='%s'",
    get_magic_quotes_gpc() ? $loginUsername :
    addslashes($loginUsername), get_magic_quotes_gpc() ? $password :
    addslashes($password));

    $LoginRS = mysql_query($LoginRS__query, $conn_newland) or
    die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);
    if ($loginFoundUser) {

    $loginStrGroup = mysql_result($LoginRS,0,'userGroup');

    //declare two session variables and assign them
    $GLOBALS['MM_Username'] = $loginUsername;
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;

    //register the session variables
    session_register("MM_Username");
    session_register("MM_UserGroup");

    if (isset($_SESSION['PrevUrl']) && true) {
    $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    }
    header("Location: ". $MM_redirectLoginSuccess );
    }
    else {
    header("Location: ". $MM_redirectLoginFailed );
    }
    }
    ?>


    John Guest

  4. #3

    Default Re: Headers already sent?

    Here's some info on the headers already sent error.

    [url]http://www.parseerror.com/php/headers_already_sent.php[/url]

    From what I know of this error (I've gotten it before, sadly, but fixed it
    by moving my headers to the top of the page) is that the headers come first!
    Not really first, but before any other output. So you can have a 'header'
    further down in the page, but it has to be before other output..

    It looks like all your code is PHP in that file, why do you use seperate PHP
    tags? if you opened one PHP tag at the beginning and closed the same tag at
    the very end, (if that's possible for you), maybe it will read all the
    headers as one chunk and accept it.

    Another weird thing about headers is they hate white space.. so your first
    "<?php", make sure there isn't a blank line or a space before it.

    Just some thoughts to try, still learning the basics myself!

    ~Chris

    <snip>


    Chris Martin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139