PHP Classes

Trouble Drawing Dynamically

Recommend this page to a friend!

      Pie Graph  >  All threads  >  Trouble Drawing Dynamically  >  (Un) Subscribe thread alerts  
Subject:Trouble Drawing Dynamically
Summary:Functions fails with "The image cannot be displayed ... errors"
Messages:2
Author:K. Schweigert
Date:2006-08-24 02:57:12
Update:2006-08-24 13:55:30
 

  1. Trouble Drawing Dynamically   Reply   Report abuse  
Picture of K. Schweigert K. Schweigert - 2006-08-24 02:57:12
I am trying to use the class to return an image by referencing it like:

echo "<img src=\"piegraph.image.php?userid=" . $userid . "&titleid=" . $titleid . "\">";

In piegraph.image.php I take the supplied GET values and use them as arguments to a function that queries the database and returns an array.

Code snippet:

require("piegraph.class.php");
require("functions.php");
$a = array();
$a = get_my_issues_in_title($userid,$titleid);
$pie = new PieGraph(200, 100, array(3,127));
$pie->setColors(array("#19a000","#e5e5e5"));
$pie->setLegends(array("$userid","$titleid"));
$pie->DisplayCreationTime();
$pie->set3dHeight(15);
$pie->display();

If I hit "piegraph.image.php?userid=1&titleid=1" it returns "The image cannot be displayed, because it contains errors." However, if I comment out the line to get_my_issues_in_title() it renders the graph perfectly. The legend even has the values passed to it from the GET variables.

Thinking my function might be sending something that was corrupting the image, I put a header() redirect after each line and stepped through it and the page redirected each time; didn't get the "headers have been already sent" error.

I don't understand how this one line could be crashing the class.

Can anyone help me figure it out?

-ken

  2. Re: Trouble Drawing Dynamically   Reply   Report abuse  
Picture of K. Schweigert K. Schweigert - 2006-08-24 13:55:30 - In reply to message 1 from K. Schweigert
Well, I figured it out and it was nothing to do with the class. I had an extra line return at the end of my functions.php file that I had as a require() and that was corrupting the image. Once it was removed, all was well.