Imagettfbbox and imagettftext errors

I have been having the error below since yesterday and dont have a clue of how to get it sorted: Thx.

Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 70

Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 76

Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 82

Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 87

Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 91

Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 82

Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 87

Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 91

Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 82

Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 87

Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 91

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\VertrigoServ\www\widgets\polls.php:70) in C:\Program Files\VertrigoServ\www\widgets\polls.php on line 94
‰PNG  IHDRôæ¬ÝàùîIDATxœíݱm;EQ^ã5¦Î¤Îԝ8rð@j¿µ*8€;à\ €œYkí½OÏà13óëôž’îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$îAâ$™Óþw€ qašµÖÞûôŒ‚ùø:=á]}ž^À»»¢3ó:½pÛÑâÜù¿Íµ @¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸‰;@¸½N€aÌÌé p—Ykí½OÏ(˜_¸Á̸–w€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ u¾NOø!¾?O/€‡ÝVÑ™ñÌaÜvà_ÜùÊ£k€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qazÀ;š™Ó nÖZ{ïÓ3 fÆ—n03®e‚Ä HÜ‚Ä HÜ‚Ä HÜ‚Ä HÜ‚Ä HÜ‚Ä HÜ‚Ä HÜ‚Ä Èc™¯Ó¾?O/€ÿí¶ŠÎŒgö¸Îmçþ۝ÏFº–w€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ qaw€ ×éð·™9=~¼Ykí½OÏ(˜_¸Á̸–w€ qaw€ qŒ¿©À=Ä HÜ‚Ä HÜ‚Ä HÜ‚Ä HÜ‚Ä HÜ‚Ä HÜà’ø +h:×-ž¤ðIEND®B`‚

I thank you and pmw57 for d help.

It worked after putting the font file in another directory as advised.

Sorry for hi jacking the former thread …

Thx once again.

Take it back to what worked, then move forward steadily until you determine what it is that’s causing the problem.

You do have a previous version that works don’t you? If not, you can always restart again.

Thx…that was one of the crazy changes that i made when i had no clue about what to do next.

I have changed it back to: $font = ‘arial’; but the error is exactly the same as before.

Help! Help!! Help!!!

Should $font have …

woah, earthquake aftershocks.

Ok, should $font have spaces in its name?


$font =' arial ';

This is the PHP Code that caused the above error.

<?php
$vote=$_REQUEST[‘vote’];
if (!$db_conn= new mysqli(‘localhost’, ‘root’, ‘sitepoint’, ‘poll’))
{
echo ‘cant connet to db <br/>’;
exit;

}
if(!empty($vote)){
$vote= addslashes($vote);
$query= “update poll_results
set num_votes = num_votes + 1
where candidate = ‘$vote’”;
if(!($result = @$db_conn->query($query)))
{
echo ’ cant connect to db <br/>';
exit;
}
}
$query= ‘select * from poll_results’;
if(!($result = @$db_conn->query($query)))
{
echo ‘cant connect to db2<br/>’;
exit;
}
$num_candidates = $result->num_rows;
$total_votes = 0;
while($row = $result->fetch_object())
{
$total_votes += $row->num_votes;

}
$result-> data_seek(0);

//cal for graph:

putenv(‘GDFONTPATH=C:\WINDOWS\Fonts’);
$width= 500;
$left_margin = 50;
$right_margin= 50;
$bar_height= 40;
$bar_spacing = $bar_height/2;
$font =’ arial ';
$title_size=16;
$main_size=12;
$small_size= 12;
$text_indent= 10;
$x= $left_margin + 60;
$y = 50;
$bar_unit = ($width-($x+$right_margin))/100;
$height=$num_candidates*($bar_height+$bar_spacing)+50;
//set up bae canvas

$im= imagecreatetruecolor($width, $height);
$white= imagecolorallocate($im,255,255,255);
$blue= imagecolorallocate($im, 0, 64, 128);
$black=imagecolorallocate($im,0,0,0);
$pink= imagecolorallocate($im, 255, 78, 243);
$text_color= $black;
$percent_color=$black;
$bg_color= $white;
$line_color= $black;
$bar_color= $blue;
$number_color=$pink;

imagefilledrectangle($im,0,0,$width,$height,$bg_color);

imagerectangle($im,0,0,$width-1,$height-1,$line_color);
$title = ‘poll results’;
$title_dimensions = imagettfbbox($title_size, 0, $font, $title);
$title_lenght = $title_dimensions[2]-$title_dimensions[0];
$title_height=abs($title_dimensions[7]- $title_dimensions[1]);
$title_above_line=abs($title_dimensions[7]);
$title_x=($width-$title_lenght)/2;
$title_y = ($y - $title_height)/2 + $title_above_line;
imagettftext($im, $title_size,0, $title_x,$title_y,$text_color, $font, $title);
imageline($im, $x,$y-5, $x,$height-15,$line_color);
while($row= $result->fetch_object()) {
if($total_votes > 0)
$percent = intval(($row->num_votes/$total_votes)100);
else $percent =0;
$percent_dimensions = imagettfbbox($main_size, 0, $font, $percent.‘%’);
$bar_lenght = $x+($percent
$bar_unit);

imagefilledrectangle($im, $x, $y-2, $bar_lenght, $y+ $bar_height,$bar_color);
 imagettftext($im, $main_size,0,$text_indent, $y+($bar_height/2),
              $text_color,$font,"$row-&gt;candidate");
 imagerectangle($im, $bar_lenght+1, $y-2,
                ($x+(100*$bar_unit)),$y+$bar_height,$line_color );
 imagettftext($im, $small_size,0,$x+(100*$bar_unit)-50, $y+($bar_height/2),
              $number_color,$font,$row-&gt;num_votes.'/'.$total_votes);
 $y=$y+($bar_height+$bar_spacing);
 }
 header('content-type:image/png');
 imagepng($im);
 imagedestroy($im); 

?>

Good idea, the appropriate posts are now in this new thread.

For a function like that… try copying the arial.ttf and putting it in the same directory.

Then rid of this line: putenv(‘GDFONTPATH=C:\WINDOWS\Fonts’);

And specify the font extension in your var: arial.ttf

P.S. You really shoudl have made your own thread instead of hi-jacking this one. But as long as your problem gets solved I suppose…