Hi
I am trying to run this code for long but failed.Can anyone help me?
1. <?php
2. $button_text=$_POST['button_text'];
3. $color=$_POST['color'];
4.
5. if(empty($button_text)||empty($color))
6. {
7. echo 'Could not create image - form not filled out correctly';
8. exit;
9. }
10. $imgname="I:\xampp\htdocs\test\button\";
11. $im=imagecreatefrompng('$imgname'.$color.'-button.png');
12. $width_image=imagesx($im);
13. $height_image=imagesx($im);
14. $width_image_wo_margins=$width_image-(2*18);
15. $height_image_wo_margins=$height_image-(2*18);
16. $font_size=33;
17. putenv('GDFONTPATH=C:\WINDOWS\Fonts');
18. $fontname='arial';
19. do
20. {
21. $font_size--;
22. $bbox=imagettfbbox($font_size,0,$fontname,$button_text);
23. $right_text=$bbox[2];
24. $left_text=$bbox[0];
25. $width_text=$right_text - $left_text;
26. $height_text=abs($bbox[7]-$bbox[1]);
27. }while($font_size>8 && ($height_text>$height_image_wo_margins||$width_text>$width_image_wo_margins));
28.
29. if($height_text>$height_image_wo_margins||$width_text>$width_image_wo_margins)
30. {
31. echo 'Text given will not fit on button.<br>';
32. }
33. else
34. {
35. $text_x=$width_image/2.0 - $width_text/2.0;
36. $text_y=$height_image/2.0 - $height_text/2.0;
37.
38. if($left_text<0)
39. $text_x+=abs($left_text);
40. $above_line_text=abs($bbox[7]);
41. $text_y +=$above_line_text;
42. $text_y -=2;
43. $white=imagecolorallocate($im,255,255,255);
44. imagettftext($im,$font_size,0,$text_x,$text_y,$white,$fontname,$button_text);
45. header('content-type:image/png');
46. imagepng($im);
47. }
48. imagedestroy($im);
49. ?>
But I am getting the error -
Parse error: syntax error, unexpected $end in D:\xampp\htdocs\web\button\make_button.php on line 49