So ... I have this on a page :
$width=$coef*130;
echo "<p align=\"left\"><img src=\"image.php\"> ".$choice."<small> (".$mycount.")</small></p>";
and image.php contains the following :
<?php
header("Content-type: image/gif");
$im = imagecreate(130, 3);
$black = imagecolorallocate($im, 0, 0, 0);
$red = imagecolorallocate($im, 255, 0, 0);
imagefilledrectangle($im,0, 0, $width, 3, $red);
imagegif($im);
?>
But the red part doesn't appear , and I think it has something to do with $width , the imagefilledrectangle() doesn't get the $width ...
Can you please help me ?
need help with GD
Moderator: General Moderators
Re: need help with GD
You're right about the issue. The image is a separate script entirely. It can't access any variables set in the page script. Either pass the width as a GET variable (eg call the image with image.php?width=$width ), or calculate the width value in the image script in the same way you calculate it in the page script, or put the width value in the session and retrieve it in the image script.
Re: need help with GD
indeed...$_GET['width']...
Thanks !! is there a way I can give a +1 or a up ?
Thanks !! is there a way I can give a +1 or a up ?
Re: need help with GD
No, we don't do that here. Besides, everyone already knows I'm awesome.
indeed!