[!--quoteo(post=382181:date=Jun 10 2006, 03:28 AM:name=babak83)--][div class=\'quotetop\']QUOTE(babak83 @ Jun 10 2006, 03:28 AM) [snapback]382181[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hello every one ! I have written the following code for showing the results of a poll in my site but it dose not working (in firefox it says : "The image “http://127.0.0.1/poll/Poll.php” cannot be displayed, because it contains errors.") Please help me solve the problem .Tanks in advance [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] <?php header ("Content-type: image/png"); $vote=$_POST['vote']; if(! $db_conn=@mysql_connect("localhost","babak","159753")) { echo'Error ! Cannot Connect to DB !!'; exit; } @mysql_select_db('poll'); if (!empty($vote)) { $vote = addslashes($vote); $query="update poll_resuls set num_votes = num_votes + 1 where candidate = '$vote'"; if (!($result=@mysql_query($query, $db_conn))) echo 'Error !! Could Not execute The Query !'; exit; } else { echo'Go Back and Compelete The form'; } $query ='select * from poll_resuls'; if(!($result = @mysql_query($query, $db_conn))) { echo 'Error !! Can not connect to db !'; } $num_candidate = mysql_num_rows($result); $total_votes = 0; while ($row = mysql_fetch_object ($result)) { $total_votes+= $row->num_votes; } mysql_data_seek($result, 0); //***********************graphic*************************** $width=500; $left_margin=50; $right_margin=50; $bar_height=40; $bar_spacing=$bar_height/2; $font='c:\windows\fonts\arial.TTF'; $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_candidate * ($bar_height + $bar_spacing) +50; $im = imagecreate($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; $bg_color=$white; $line_color=$black; $bar_color=$blue; $number_color=$pink; ImageFilledRegtangle( $im, 0, 0, $width, $height, $bg, $bg_color); ImageRegtangle( $im, 0, 0, $width-1, $height-1, $line_color); $title='Poll Results :'; $title_dimensions=ImageTTFBBox( $title_size, 0, $font, $title); $title_length=$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_length)/2; $title_y=($y - $title_height)/2 + $title_above_line; ImageString($im, $title_size, $title_x, $title_y, $title, $text_color); ImageLine($im, $x, $y-5, $x, $height-15, $line_color); while($row = mysql_fetch_object($result)) { if($total_votes > 0) $percent = intval(round(($row->num_votes/$total_votes)*100)); else $percent=0; ImageString($im, $main_size, $width-30, $y+($bar_height/2), $percent.'%', $percent_color); if($total_votes > 0) $right_value= intval(round(($row->num_votes/$total_votes)*100)); else $right_value = 0; $bar_length= $x+($right_value * $bar_unit); ImageFilledRegtangle($im, $x, $y-2, $bar_length, $y+$bar_height, $bar_color); ImageString($im,$main_size,$text_indent,$y+($bar_height/2),"$row->candidate", $text_color); ImageRegtangle($im,$bar_length+1,$y-2,($x+(100*$bar_unit)), $y+$bar_height, $line_color); ImageString($im,$small_size, $x+(100*$bar_unit)-50, $y+($bar_heigth/2), $row->num_votes.'/'.$total_votes, $number_color); $y=$y+($bar_height + $bar_spacing); } ImagePng ($im); ImageDestroy($im); ?> [/quote]