PHPでJpGraphを使ってグラフが表示できません。どなたか教えていただきませんでしょうか?
phpMyAdminからデータを読み込んでます。
スプリクトは下記の通りです。
$date=$year;
/* SQLサーバに接続 /
$conn_id = mysql_connect("※※※.lolipop.jp", "△△△△", "○○○") or die ('Error connecting to mySQL server');
mysql_query('SET NAMES ujis', $conn_id );
/ DBを選択 /
mysql_select_db("LAA0231516-vege", $conn_id);
/ examsテーブルから使用量を取得する /
$sql ="SELECT hiyou,SUM(shishutu) AS G FROM sdat_sales_product WHERE code =".mysql_real_escape_string($_SESSION['smember_code'])." AND shishutu <>'0'AND DATE >='$date-01-01'AND DATE <='$date-12-31' GROUP BY hiyou";
ob_start('Content-type: text/plain; charset=UTF-8');
$result = mysql_query($sql, $conn_id) or die ($sql . ' failed (' . mysql_error() . ')');
echo "$date年支払";
/ データを配列に格納する /
while ($row = mysql_fetch_object($result)) {
$hiyou = $row->hiyou;
$hiyou = mb_convert_encoding($hiyou, 'UTF-8', 'eucJP-win');
array_push($ydata, $row->G);
array_push($a, $hiyou);
}
mysql_free_result($result);
/ SQLサーバから切断 */
mysql_close($conn_id);
/* グラフ作成 */
$graph = new PieGraph(500, 500, "auto");
$graph->legend->SetFont(FF_MINCHO, FS_NORMAL);
$graph->SetFrame(true);
/* X軸項目追加 /
$pieplot = new PiePlot($ydata);
/ plot作成 /
$pieplot->SetLegends($a);
/ グラフ上に描画 /
$graph->Add($pieplot);
/ グラフ表示 */
$graph->Stroke();
?>
このスプリクトでJpGraphで円グラフを表示させたいのですが下記のエラーメッセージが表示されます。
JpGraph Error: HTTP headers have already been sent.
Caused by output from file sheihi_download5.php at line 12.
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".
すみませんがよろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/04/07 00:10