ส่วนที่ขึ้น error JpGraph Error: HTTP headers have already been sent. Caused by output from file result.php at line
Code
ส่วนที่ขึ้น error JpGraph Error: HTTP headers have already been sent. Caused by output from file result.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
Code (PHP)
<?php
include("dbconn.inc.php");
if (!isset($_SESSION)) {
session_start();
}
$topic_id = $_GET['tid'];
$qid = $_GET['qid'];
$sql = "SELECT title, num_votes FROM topic WHERE topic_id = $topic_id;";
$result = mysql_query($sql);
$num_votes = mysql_result($result, 0, "num_votes");
if($num_votes == 0) {
die("<h2>�ѧ����ռ����ǵ��Ǣ���</h2>");
}
$sql = "select * from guestion where ques_id = $qid order by ques_id;";
$resultmain = mysql_query($sql);
while ($datamain = mysql_fetch_array($resultmain)) { // loop table question
$question = $datamain['ques_title'];
include("JpGraph/src/jpgraph.php");
include("JpGraph/src/jpgraph_pie.php");
$g = new PieGraph(500, 500);
$title = "ผลลัพธ์";
$g->title->Set($title);
$g->title->SetFont(FF_JASMINE, FS_BOLD, 18);
$topic = mysql_result($result, 0, "title");
$subtitle = $question;
$g->subtitle->Set($subtitle);
$g->subtitle->SetFont(FF_CORDIA, FS_NORMAL, 16);
$sql = "SELECT * FROM choice WHERE ques_id = $qid;";
$result = mysql_query($sql);
$legends = array();
$data_graph = array();
while($data = mysql_fetch_array($result)) {
$lg = $data['item'];
array_push($legends, $lg);
array_push($data_graph, $data['score']);
}
$pie = new PiePlot($data_graph);
$pie->SetLegends($legends);
$g->legend->SetFont(FF_CORDIA, FS_NORMAL, 12);
$g->Add($pie);
$g->Stroke();
?>
<? } ?>
Tag : PHP
Date :
2011-09-25 00:52:36
By :
jub
View :
1154
Reply :
3
ลองเช็คไฟล์ UTF-8 + BOM ครับ ปกติ JPGraph จะต้องเรียกอ้าง <img src="view.php"> ประมาณนี้ครับ โดยรูปภาพจะต้องสร้างไว้ที่ไฟล์ view.php
Date :
2011-09-25 07:37:38
By :
webmaster
ไฟล์ connection.php หรอค่ะ
ช่วยดูโค้ดหน่อยนะค่ะ ขอบคุณค่ะ
Code (PHP)
<?php
$host="localhost";
$queusername="root";
$quepassword="1234";
$dbname="dbonline_survey";
$conn=mysql_connect($host,$queusername,$quepassword);
mysql_select_db($dbname,$conn);
mysql_query("SET NAMES UTF8");
if($conn)
echo"";
else{
mysql_query ("SET NAMES utf-8");
mysql_query("SET collection_connection = 'utf-8';");
echo"ติดต่อกับฐานข้อมูลไม่ได้";
}
?>
Date :
2011-09-25 19:07:09
By :
jub
แก้ตามที่เว็บบอกแล้วค่ะ ให้เป็นภาษาไทย แต่ก็ยังไม่ได้
Date :
2011-09-25 21:57:44
By :
jub
Load balance : Server 00