Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating an image problem

Status
Not open for further replies.

sarbruis

Programmer
Aug 19, 2004
5
US
I'm just trying to make a rectangle appear and I'm using the code (only a variable name change and a color change were made) example in the Core PHP book I bought:

<?php

$image = imagecreate(200,200);
$buttoncolor = imagecolorallocate($image,191,241,113);
imagefill($image, 0, 0, $buttoncolor);

imagefilledrectangle($image, 10, 10, 90, 90, $buttoncolor);

header("Content-type: image/png");
imagepng($image);

?>

When I choose the 'Run and redirect output to file' option on my IDE, then click the HTML file on the desktop it creates, I get the following output: ‰PNG (and a square character--not the rectangle). I've also tried <img src>ing the PHP file in a separate HTML file, but I've had no success. I've also tried different image file-types, but that doesn't work.

Please help me.

Thanks a lot.
 
Are you sure you have GD or similar on your server and it's enabled?

----------------------------------------
Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
 
did the core php example work (what page I've got it I can try when i get home)
 
it's p. 601 or around there. no, it didn't work, that's why i'm asking the question.

and darncat: I'm just running it off my home computer, and i have taken the semi-colon out (in php.ini) and changed the extension.
 
soory to be so long can you do a php -m from your commnad line it shpuld list gd as a loaded module. If it wasn't there you should get an error telling you that you are callijng a non existent function.
The reason I asked if the core php example worked is I'm trying to see if the change you made is the cause of the problem. Can you use the original and see describe here what happens
In any case it works on my PC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top