Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005
    Posts
    40

    Unanswered: Cannot modify header information - headers already sent by

    Cannot modify header information - headers already sent by

    This is the message when i enter the below small source code :
    <?php
    header("Content-Type: image/gif");
    $im = ImageCreate(100, 100);
    // colors...
    $black = ImageColorAllocate($im, 0, 0, 0);
    $white = ImageColorAllocate($im, 255, 255, 255);
    // draw rectangle
    ImageFilledRectangle($im, 25, 25, 75, 75, $white);
    // Print and destroy the image
    ImageGIF($im);
    ImageDestroy($im);
    ?>

    After that message i get a lot of unrecognizable string characters ...

    What is wrong ????? Anyone?

  2. #2
    Join Date
    Mar 2004
    Location
    UK
    Posts
    30
    thats because you are viewing the page as a php page but setting the encoding type to a image.

    if you want the image to print out on the page then you don't need the header content-type line. the php GD library should take care of creating the image.

    if you want the image to be a dynamic reference then you will need to call if from another page, for example if your code is in myPic.php then in index.php you put

    <img src="myPic.php" height="x" width="y" alt="z" /> to call the dynamically created image.

Posting Permissions

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