Warning:Cannot modify header information

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gubbachchi
    New Member
    • Jan 2008
    • 59

    Warning:Cannot modify header information

    Hi,

    I have written php code to retrive the image from mysql and display it on the webpage. Here is the code

    <?php
    require_once("D BConnect.php");
    $gotten = @mysql_query("s elect user_photo from User_Info_Other where user_id = '1'");
    header("Content-type: image/gif");
    while ($row = mysql_fetch_arr ay($gotten))
    {
    print $row['user_photo'];
    }
    ?>

    This works fine when I don't add any html tags and displays the image, but when I add html tags i get the warning and prints the encrypted data.

    Warning: Cannot modify header information - headers already sent by (output started at /var/www/kilorie/kil_ver3/list.php:2) in /var/www/kilorie/kil_ver3/list.php on line 6

    According to what I know is, this error occurs when there are white spaces before and after the opening and closing php tags, but for my application I need to add html and css codes.

    How to solve this issue. Can anyone please help me.

    With regards
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    Hi,

    The problem here is that your outputing a charachter or whitespace before you change the headers.

    If you post your markup for this page we can spot it.

    Comment

    • gubbachchi
      New Member
      • Jan 2008
      • 59

      #3
      Thank you for the reply.
      I have solved the problem, it is working now.

      Comment

      • harshmaul
        Recognized Expert Contributor
        • Jul 2007
        • 490

        #4
        hi,
        Thats good news :)

        Comment

        Working...