473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

working with jpgraph

250 100+
im using jp graph and i want to put a graph code at the middle of my table. Then I got error:
JpGraph Error: HTTP headers have already been sent.
Caused by output from file test.php at line 2.
Explanation:
HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it's image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).

Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser.

For example it is a common mistake to leave a blank line before the opening "<?php".


Could anyone tell me how can i solve that?
Apr 9 '08 #1
9 8551
TheServant
1,168 Expert 1GB
I'm confused? Did u check the top of the page where it says <?php ? Straight after the word php, if there is a space (black character) you will have a problem. That's what your post says, so you would already know that. Can you post the codefor the jpgraph? If it's too big, post your page code (mainly where your header is) and then have a look in the jpgraph code for the word header and post surrounding code for that.
Apr 9 '08 #2
ghjk
250 100+
I'm confused? Did u check the top of the page where it says <?php ? Straight after the word php, if there is a space (black character) you will have a problem. That's what your post says, so you would already know that. Can you post the codefor the jpgraph? If it's too big, post your page code (mainly where your header is) and then have a look in the jpgraph code for the word header and post surrounding code for that.
Thanks for your reply. This is my graph code and this is working.
[PHP]
<?php
include ("../rainfall_ITI/jpgraph2.3/src/jpgraph.php");
include ("../rainfall_ITI/jpgraph2.3/src/jpgraph_bar.php");
include 'dbconnect.php';

$sql = mysql_query("SELECT Rainfall,Date FROM rainfall WHERE Station_ID = 'st1 St 02' LIMIT 0, 10") or die(
mysql_error());


while($row = mysql_fetch_array($sql))
{
$i=0;

$Query1 = explode(" ",$row['Date']);
$Query2 = $Query1[0];

$data[] = $row[0];
$leg[] = $Query2[8].$Query2[9];

}

$graph = new Graph(300,300,"auto");// set the size of the image
$graph->SetScale("textint");
$graph->img->SetMargin(40,30,30,60);
//$graph->AdjBackgroundImage(0.4,0.7,-1); //setting BG type
//$graph->SetBackgroundImage("linux_pez.png",BGIMG_FILLFRAM E); //adding image
$graph->SetShadow();

$graph->xaxis->SetTickLabels($leg);
$bplot = new BarPlot($data);
$bplot->SetFillColor("darkblue"); // Fill color

// Set up the title for the graph
//$graph->title->Set("Rainfall During last 10 hours"."($Query2)");
$graph->title->Set("Rainfall During last 10 hours");
$graph->title->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->title->SetColor("darkred");

// Setup X-axis labels
$graph->xaxis->title->Set("Date");
//$graph->xaxis->SetLabelAngle(90);
$graph->yaxis->title->Set("Rainfall(mm)");

$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(45);
$bplot->value->SetColor("black","navy");

$graph->Add($bplot);
$graph->Stroke(); ?>

[/PHP]


when i put the above code in to my table it gave an error
[PHP]
<table>
<tr>
<td width="60">&nbsp;</td>
<td>
/* jp graph code add here*/
</td>
</tr>
</table>
[/PHP]
Apr 9 '08 #3
TheServant
1,168 Expert 1GB
Are there any headers set in
"../rainfall_ITI/jpgraph2.3/src/jpgraph.php" and "../rainfall_ITI/jpgraph2.3/src/jpgraph_bar.php"
Apr 9 '08 #4
ghjk
250 100+
Are there any headers set in
"../rainfall_ITI/jpgraph2.3/src/jpgraph.php" and "../rainfall_ITI/jpgraph2.3/src/jpgraph_bar.php"
This is the first few lines in jpgraph.php
[PHP]
<?php
//================================================== =====================
// File: JPGRAPH.PHP
// Description: PHP Graph Plotting library. Base module.
// Created: 2001-01-08
// Ver: $Id: jpgraph.php 957 2007-12-01 14:00:29Z ljp $
//
// Copyright 2006 (c) Aditus Consulting. All rights reserved.
//================================================== ======================

require_once('jpg-config.inc.php');
require_once('jpgraph_gradient.php');
require_once('jpgraph_errhandler.inc.php');
require_once('jpgraph_ttf.inc.php');

// Version info
DEFINE('JPG_VERSION','2.3');

// Minimum required PHP version
DEFINE('MIN_PHPVERSION','5.1.0');

// Should the image be a truecolor image?
DEFINE('USE_TRUECOLOR',true);
..................................

[/PHP]
Apr 9 '08 #5
TheServant
1,168 Expert 1GB
If it's a header problem, it's likely to be in one of those files. Provided you ahven't changed any orders of those include commands from the original set up, my bet would be 'jpg-config.inc.php'. What I am looking for and what you can look for is the php function header() like header(Location:somepage.php). If you can find that, there's where your prob is. I hope I'm not leading you on a wild goose chase, but if you're getting a header warning it's a good thing to look for. Another thing is do you have session_start() anywhere?
Apr 9 '08 #6
ghjk
250 100+
If it's a header problem, it's likely to be in one of those files. Provided you ahven't changed any orders of those include commands from the original set up, my bet would be 'jpg-config.inc.php'. What I am looking for and what you can look for is the php function header() like header(Location:somepage.php). If you can find that, there's where your prob is. I hope I'm not leading you on a wild goose chase, but if you're getting a header warning it's a good thing to look for. Another thing is do you have session_start() anywhere?

Thanks for your reply. But i could not understand about header thing? I don't have session_start() in any jpgraph pages. but having all my ather pages.
Apr 9 '08 #7
when i put the above code in to my table it gave an error
[PHP]
<table>
<tr>
<td width="60">&nbsp;</td>
<td>
/* jp graph code add here*/
</td>
</tr>
</table>
[/PHP]
I don't think you can use jp Graph code like this inside a table or even inside a html file.
It must be a separate pure php file. Otherwise if server found any html code before your php code, it will start sending them to browser before processing your jp Graph code and so you will get an error like header already send.
To solve this, I think you can can create a separate jp Graph file with the code you have, run the code, save the graph image and display it inside your table. To get the updated image, you have to run the jp Graph file and save the image automatically.

Thanks
Apr 9 '08 #8
ghjk
250 100+
I don't think you can use jp Graph code like this inside a table or even inside a html file.
It must be a separate pure php file. Otherwise if server found any html code before your php code, it will start sending them to browser before processing your jp Graph code and so you will get an error like header already send.
To solve this, I think you can can create a separate jp Graph file with the code you have, run the code, save the graph image and display it inside your table. To get the updated image, you have to run the jp Graph file and save the image automatically.

Thanks
Could you please tell me how can i do that? Really in a trouble..
Apr 10 '08 #9
Could you please tell me how can i do that? Really in a trouble..
You just create a php file for you graph. Then at the end in the graph->stroke() function give a path to where you want to save the graph image.

[PHP]graph->stroke('file path');[/PHP]

See if it is saved or not. The path must have a file permission to save the image. If its done then you put the hole code inside a function. Pass all parameters the function requires and call it in your pages. Every time your page loads the function will be called and the image will be replaced with the updated one. Then you can show the saved image anywhere you want.

You function should be defined before you call it.

:)
Apr 10 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Leigh Riley | last post by:
Hi there, I've installed PHP on a variety of machines, but I seem to be having a lot of trouble on Windows XP. I have 4.3.2 installed, and I would like to use...
0
by: Andrew Rich | last post by:
anybody done linear regression with jpgraph ?
3
by: JÿGius³ vs ::NRG::ius | last post by:
Hi all. How can I draw a table with jpgraph? I want a table as image. Thanks. G:
2
by: iulian.ilea | last post by:
Hi, I use JpGraph to generate some graphs and I have to include those graphs in a pdf file, generated usign fPDF (http://www.fpdf.org/). If I include a png file it's ok, the pdf file is...
3
by: rahmawaktu | last post by:
Dear list, i am new to this forum and to JPGraph too. I just install jpgraph to create a graphic to my website. But i got error. Here is the complete code : First is MySQL Database : ( 2...
0
by: luckyG | last post by:
I have php (5.2.4) compiled on redhat 4.0 as followed : ./configure \ --with-oci8=$ORACLE_HOME --with-apxs=/usr/local/apache/bin/apxs \ --with-config-file-path=/usr/local/apache/conf \ ...
2
by: paeh | last post by:
what's wrong for this php code. when I run did not display anything in browser.. this is code: <?php include ("C:/Program Files/Apache Software...
2
by: AARTHISUBBU | last post by:
i m quiet new to wamp... is it possible to run jpgraph codes in wamp... else i have to install jpgraph separately and to run?.. if i can run jpgraph codes in wamp,what i have to do? i m using...
0
by: eureka2050 | last post by:
Hi all, I am creating a radar chart containing 2 plots using jpgraph. My code is as follows:- include ("./jpgraph/src/jpgraph.php"); include ("./jpgraph/src/jpgraph_radar.php"); //...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.