[prog] On the fly graphs with php
Conor Daly
conor.daly-linuxchix at cod.homelinux.org
Fri Jul 15 05:26:22 EST 2005
On Thu, Jul 14, 2005 at 03:03:43PM -0400 or so it is rumoured hereabouts,
Clifford Crawford thought:
> On 2005/07/14, at 13:59, Conor Daly wrote:
>
> >However, if I
> >
> >include("chart.php");
> >
> >I get a "cannot send header" error since other stuff has already
> >happened.
>
> My guess is this is what needs to be fixed; you need to be able to
> set the header to "image/png" so that the browser can correctly
> interpret the data. What exactly do you mean by "other stuff has
> already happened"? Is it outputting something before showImage() is
> called? If it does, then PHP might be setting the header to "text/
> html" behind your back. Also, check for any stray spaces or anything
> outside of <? ?> tags, that could cause the header to be set wrong too.
Sorry, I'm probably not being clear here. When running in test mode where
I define the data to plot within chart.php, I can use an
<img src="chart.php">
to load the image. At this point, showImage() is sending the correct
header (I don't have the code in front of me now so it's from memory).
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...
Conor
--
Conor Daly <conor.daly at oceanfree.net>
Domestic Sysadmin :-)
---------------------
Hobbiton.cod.ie
20:17:51 up 7 days, 23:12, 1 user, load average: 0.02, 0.02, 0.00
More information about the Programming
mailing list