View previous topic :: View next topic |
Author |
Message |
ghirlandaio -
Joined: 29 May 2005 Posts: 4
|
Posted: Sat Sep 30, 2006 10:25 am Post subject: Problem with GD |
|
|
I've a problem with GD libraries in my PHP (5.1.4) scripts.
I set correctly my extension dir in PHP.INI and uncommented php_gd2.dll.
When i try this simple script:
<?php
$height = 15;
$width = 100;
$immagine = imagecreate($width, $height);
$bg = imagecolorallocate($immagine, 255, 255, 255); // bianco
$barra = imagecolorallocate($immagine, 0, 255, 0);
imagefilledrectangle($immagine, 0, 0, $width, $height, $barra);
imagerectangle($immagine, 0, 0, $width, $height, $bg);
header("Content-type: image/png");
imagepng($immagine);
imagedestroy($immagine);
?>
The browser shows this sequence of strange caracters:
‰PNG IHDRd(øŽPLTEÿÿÿÿÆæ. IDATxœc`@õÿàÃÐäGŒy'yr‘IEND®B`‚
There is a particular setting of Abyss WebServer in order to do GD functioning? Could you help me? |
|
Back to top |
|
|
Mikor -
Joined: 21 Aug 2006 Posts: 144 Location: Hull, England
|
Posted: Sat Sep 30, 2006 10:33 am Post subject: |
|
|
Try using the aprelium pre-configured php package _________________ Yarrt.com - Free Arcade
RypNet.co.uk - Online Game
MSN: michael_walker_2004 <at> hotmail <dot> com |
|
Back to top |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Sat Sep 30, 2006 10:55 am Post subject: Re: Problem with GD |
|
|
ghirlandaio wrote: | The browser shows this sequence of strange caracters:
‰PNG IHDRd(øŽPLTEÿÿÿÿÆæ. IDATxœc`@õÿàÃÐäGŒy'yr‘IEND®B`‚
There is a particular setting of Abyss WebServer in order to do GD functioning? Could you help me? |
ghirlandaio, that strange sequence of characters is the image!
have you tried moving the header() to the top of the page?
Code: | <?php
header("Content-type: image/png");
$height = 15;
$width = 100;
$immagine = imagecreate($width, $height);
$bg = imagecolorallocate($immagine, 255, 255, 255); // bianco
$barra = imagecolorallocate($immagine, 0, 255, 0);
imagefilledrectangle($immagine, 0, 0, $width, $height, $barra);
imagerectangle($immagine, 0, 0, $width, $height, $bg);
imagepng($immagine);
imagedestroy($immagine);
?> |
_________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
|
ghirlandaio -
Joined: 29 May 2005 Posts: 4
|
Posted: Sat Sep 30, 2006 2:28 pm Post subject: |
|
|
For mikor: I tried to use preconfigred package... same error!
For roganty: yes, I tried moving the header() to the top of the page, but there is the same problem! In IE the result is the sequence of "strange characters", in Mozilla "The image http://localhost/www/immagine2.php cannot be visualized because it has errors"
Anyone can help me? |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Sep 30, 2006 2:47 pm Post subject: |
|
|
ghirlandaio,
We tested the code as updated by Roganty and it worked fine on IE and Opera.
Are you sure there are no characters (even hidden ones) before <?php? Try refreshing the page you have visited in the browser after updating the code. Your browser could be giving you the old copy from its cache without actually calling the server (or try with another filename to force it to contact the server). _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
ghirlandaio -
Joined: 29 May 2005 Posts: 4
|
Posted: Sun Oct 01, 2006 2:13 pm Post subject: |
|
|
You're right!
It is my fault... for my little experience in PHP! I writed the ordinary HTML tags
(<html><head><title></title></head></body></html>) before and after the script!
Thanks very much! :D |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|