Cannot modify header information - Headers already sent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • half21back
    New Member
    • Jun 2007
    • 2

    Cannot modify header information - Headers already sent

    Can anyone tell me what is wrong with this code?

    [code=php]
    <?php
    if (isset($_COOKIE['referralcookie ']['refid'])) {
    $url = $row_rsCookieRe ferral['cookiereferral _hoplink'];

    header("Locatio n: $url");
    }
    ?>
    [/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]

    ['referralcookie ']['refid'] is a cookie I have set and
    rsCookieReferra l is a recordset I have on my page

    My main issue is that I am getting this error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/XXXMY_USERNAMEX XX/public_html/index.php:69) in /home/ezcogtem/public_html/index.php on line 73
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by half21back
    Can anyone tell me what is wrong with this code?

    <?php
    if (isset($_COOKIE['referralcookie ']['refid'])) {
    $url = $row_rsCookieRe ferral['cookiereferral _hoplink'];

    header("Locatio n: $url");
    }
    ?>




    ['referralcookie ']['refid'] is a cookie I have set and
    rsCookieReferra l is a recordset I have on my page

    My main issue is that I am getting this error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/XXXMY_USERNAMEX XX/public_html/index.php:69) in /home/ezcogtem/public_html/index.php on line 73
    Moved to PHP forum .

    Comment

    • Ajm113
      New Member
      • Jun 2007
      • 161

      #3
      Look around here:
      http://www.php.net/manual/en/function.sessio n-start.php

      Their is a command to have it so you can add spaces after session start, but I forgot...

      Comment

      • Purple
        Recognized Expert Contributor
        • May 2007
        • 404

        #4
        Hi half21back and welcome to TSDN

        The error :

        Code:
        Warning: Cannot modify header information - headers already sent by (output started at /home/XXXMY_USERNAMEXXX/public_html/index.php:69) in /home/ezcogtem/public_html/index.php on line 73
        is telling you your script has written output to the browser before you have issued your redirect - this is not allowed, thus the error. You can either find the write to the browser, this could be a php function ie echo, print() or could be as simple as whitespace in the html code around your php script. Take a look at line 73. If you cannot find the problem post the whole of index.php into this thread.

        Regards Purple

        Comment

        • half21back
          New Member
          • Jun 2007
          • 2

          #5
          Thank you guys,

          Here is the updated code:

          [PHP]
          <?php
          if (isset($_COOKIE['referralcookie ']['refid'])) {
          $url=$row_rsCoo kieReferral['cookiereferral _hoplink'];
          header("Locatio n: $url");
          }
          ?>
          [/PHP]

          My page now works correctly. I believe it had to do with the white space as mentioned.

          Regards,
          Brad

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Changed thread title to actually describe the problem.

            Comment

            Working...