kelvin Posted August 9, 2007 Share Posted August 9, 2007 hai guys, could anyone help me in writing a php pgogram to retrieve the data from table for every 5 seconds and present that retrieved data in jpgraph. i wrote code as follows: refresh.php: <?php echo('<meta http-equiv="refresh" content="5;URL=http://220.225.227.214/Ngate/refresh.php" />'); include ("C:\wamp\www\jpgraph\src\jpgraph.php"); include ("C:\wamp\www\jpgraph\src\jpgraph_log.php"); include ("C:\wamp\www\jpgraph\src\jpgraph_line.php"); $db = mysql_connect("202.63.107.102", "root","vix") or die(mysql_error()); mysql_select_db("historical_vix",$db) or die(mysql_error()); $sql = mysql_query("SELECT * FROM historicalvix") or die(mysql_error()); while($row = mysql_fetch_array($sql)) { $ydata[] = $row[1]; $y2data[] = $row[2]; $leg[] = $row[0]; } $graph = new Graph(800,500,"auto"); $graph->SetScale("int"); $graph->SetY2Scale("int"); $graph->SetShadow(); $graph->img->SetMargin(40,110,20,40); $lineplot=new LinePlot($ydata); $lineplot2=new LinePlot($y2data); $graph->xaxis->SetTickLabels($leg); $graph->Add($lineplot); $graph->AddY2($lineplot2); $graph->yaxis->SetColor('blue'); $graph->title->Set("Example with 2 Y-Scales"); $graph->xaxis->title->Set("Date---->"); $graph->yaxis->title->Set("Vix---->"); $graph->title->SetFont(FF_FONT1,FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); $lineplot->SetColor("blue"); $lineplot->SetWeight(2); $lineplot2->SetWeight(2); $lineplot->SetLegend("Plot 1"); $lineplot2->SetLegend("Plot 2"); $graph->legend->Pos(0.01,0.5,"right","center"); $graph->Stroke(); ?> and when iam running this php file in browser,i am getting following error: JpGraph Error: HTTP headers have already been sent. Caused by output from file refresh.php at line 3. 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". Please in solving the above error. Thanks in advance bye... Quote Link to comment https://forums.phpfreaks.com/topic/64021-draw-jpgraph-with-table-data-for-every-5-seconds/ Share on other sites More sharing options...
pranav_kavi Posted August 9, 2007 Share Posted August 9, 2007 Based on, Look for any text, even spaces and newlines, that might have been sent back to the browser. Double quotes are not properly closed here properly, echo('<meta http-equiv="refresh" content="5;URL=http://220.225.227.214/Ngate/refresh.php" />'); Quote Link to comment https://forums.phpfreaks.com/topic/64021-draw-jpgraph-with-table-data-for-every-5-seconds/#findComment-319128 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.