Re: PHP Version 5.1.6 versus PHP Version 4.3.10



bill wrote:
The following code works ok in php 5.1.6 but doesnt return an image in 4.3.10.
put this code in the form where the image is being placed.
<img src="random.php?str=<?php echo $str; ?>" alt="capture image" width="60" height="20" vspace="1" align="top" />

This is the random.php code

<?php
$str = $_GET['str'];

$imgX = 60;
$imgY = 20;
$image = imagecreatetruecolor(60, 20);

$backgr_col = imagecolorallocate($image, 238,239,239);
$border_col = imagecolorallocate($image, 208,208,208);
$text_col = imagecolorallocate($image, 46,60,31);

imagefilledrectangle($image, 0, 0, 60, 20, $backgr_col);
imagerectangle($image, 0, 0, 59, 19, $border_col);

$font = "VeraSe.ttf";
$font_size = 11;
$angle = 5;
$box = imagettfbbox($font_size, $angle, $font, $str);
$x = (int)($imgX - $box[4]) / 2;
$y = (int)($imgY - $box[5]) / 2;
imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $str);

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

?>
Is there something I have to do to so that the imaged is returned when using 4.3.10. The isp who is hosting the website is using this version so I have to adapt to suit.
Please can someone help I have spent hours trying to work round this.
Thanks
bill

Sorry got it working. The font was causing the problem.

Thanks for looking

bill
.



Relevant Pages

  • PHP Version 5.1.6 versus PHP Version 4.3.10
    ... The following code works ok in php 5.1.6 but doesnt return an image in 4.3.10. ... imagedestroy; ...
    (alt.php)
  • Re: How can I use a member function without create an instance of that class in PHP?
    ... bill wrote: ... I have been coding PHP for the better part of 15 years, but am just now learning the ins & outs of OOP. ... This is why static methods cannot access non-static class members. ...
    (comp.lang.php)
  • Re: Securing an Email script
    ... Bill H wrote: ... The script looks like: ... /* PHP form validation: the script checks that the Email field contains a valid email address ... error string otherwise. ...
    (comp.lang.php)
  • Re: Why is break so lame, and no goto
    ... Bill H wrote: ... For production code, I don't think a "goto" would be of any use, it ... would show sloppy programming techniques. ... I am relativly new to php, what do you mean by and to force a ...
    (comp.lang.php)
  • Re: Php and Email
    ... Bill H wrote: ... this stuff is all pretty easy and can be done with out any extra PHP code for your MTA. ... email on a server before it is accessed by an email programn such as ...
    (comp.lang.php)