Hello!
Am I an idiot?
Cannot fix a problem with image and header functions.
I try to learn how to do images.I made a php file and copied
a simple code into it:

<?
Header("Content-Type: image/gif");
$image = ImageCreate(500, 75);
$blue = ImagecolorAllocate($image, 0, 0, 255);
ImageFill($image, 1, 1, $blue);
ImageGIF($image);
ImageDestroy($image)
?>

The browser shows strange characters, the error messages says:
fatal error: Call to undefined function: imagecreate().

I cut everything and leave only:

$blue = ImagecolorAllocate($image, 0, 0, 255);
The same message comes again-fatal error: call to undefined function:
ImagecolorAllocate...

Same happens if I only leave
ImageFill($image, 1, 1, $blue);

It appears as if not a single image function was working.

Also something wrong is with the header. The error message says:
warning: Cannot modify header information - headers already sent...
But If I comment the header, it should be a gross omission...How can an image appear if its type is not specified?

I thought maybe something was wrong with gd libraries,
so I changed gif to png, then to jpeg in above code, but it didn't help.

Other functions work ok.

My machine is Apple 400 MHz PowerPC G3, Memory 384 MB SDRAM, OS X 10.3.9.
I have PHP 5.1.2, gd 2.0.28. I use Safari.

Thank you for your help.

    U are not an idiot, but u didnt read the requirements for creating images using php ...

    Requirements
    If you have the GD library (available at » http://www.boutell.com/gd/) you will also be able to create and manipulate images.

    The format of images you are able to manipulate depend on the version of GD you install, and any other libraries GD might need to access those image formats. Versions of GD older than gd-1.6 support GIF format images, and do not support PNG, where versions greater than gd-1.6 support PNG, not GIF.

      he said he already has GD. the likely problem is that he hasn't loaded the lib in PHP.ini

      what has to be done is to look for a line in php.ini that reads

      ;extension=php_gd2.dll

      and change to

      extension=php_gd2.dll

      (remove the initial ";")
      and restart the http server

        I didnt said that he doesnt have the GD library, I just copy paste the code with Requirements from the php manual, that he didnt read it and he's tring to code ...

          Thanks,bogu anf Jack McSlay,for your replies.
          Good lead,so I will get around to the gd library.Hopefully it will also help fix the header problem, if there is any relation between them. I will find out soon.
          Have a good weekend.

            Write a Reply...