[prog] On the fly graphs with php

Clifford Crawford cjc26 at cornell.edu
Fri Jul 15 06:33:07 EST 2005


On 2005/07/14, at 15:26, Conor Daly wrote:

> However, if I want to pass data to the makeImage() function, I have to
> include("foo.php"); before I access that function.  At this point, I
> need flags so that it won't attempt to output an image until the
> makeImage() function has been called first.  Otherwise, it attempts  
> to put
> a
>
> header("image/png");
>
> and fails because the calling script has already put a "text/html"  
> header
> while building the page.  So, I'm left in the situation where either I
> have to embed up to 1500 datapoints in my call to makeImage() for  
> later
> use by an
>
> <img src="chart.php">
>
> tag later in my page.  This isn't working for me yet...

Ok, I think I understand now what the problem is, you have too many  
parameters to be passing to the script in the url.  You could try  
either using a session variable, or serialize()/unserialize() and  
cookies, on an array containing all of the parameters to pass the  
data in to chart.php (probably the session variable would be easier  
if you have so many datapoints).  I.e. in the calling script do this:

<?PHP
session_start();
$_SESSION["datapoints"] = array(...); ?>
<img src="chart.php">

and then in chart.php do this:

session_start();
// now $_SESSION["datapoints"] should have the data set in the  
calling script

(I think that should work, but I typed that from memory, so you  
should probably check the session handling section of the PHP manual  
to be sure...)


--
  Cliff Crawford             ***             cjc26 at cornell.edu

"The perfection of art is to conceal art."      -- Quintilian



More information about the Programming mailing list