Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > PHP > PHP Forum > เรียนถามท่านผู้รู้ค่ะ คือดิฉันสร้างกราฟแล้วฟ้อง JpGraph Error: HTTP headers have already been sent.



 

เรียนถามท่านผู้รู้ค่ะ คือดิฉันสร้างกราฟแล้วฟ้อง JpGraph Error: HTTP headers have already been sent.

 



Topic : 057232

Guest




JpGraph Error: HTTP headers have already been sent.
Caused by output from file fview_report_cashflow_detail.php at line 10.
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".

codeที่ดิฉันเขียนไว้ดังนี้


Code (PHP)
<?php
include("JpGraph/src/jpgraph.php");
include("JpGraph/src/jpgraph_line.php");
$project =$_REQUEST['DeptCode']; 
 include("db/connect.php");
 include("function/funcdate.php"); 
$sql="SELECT o.DeptCode,o.ProjectCode, o.Amount,o.Description ,d.DeptName,o.StartDate
FROM openproject AS o  INNER JOIN department AS d ON o.DeptCode = d.DeptCode
where o.ProjectCode='$project'";
	$tebleopenproject =mysql_query($sql) or die("Error : $sql".mysql_error());
		 while($data1 = mysql_fetch_array($tebleopenproject)) {
		  $deptcodeO = $data1["DeptCode"];
		  $projectO = $data1["1"];
		  $amountO = $data1["2"];
		  $descriptionO = $data1["3"]; 
		   $depnameO = $data1['4'];
		    $startdateO = $data1['5'];
			
			list($oyear,$omonth,$oday) =explode("-",$startdateO,3);
						$oyear1 = $oyear+543;
	 } 
	//**********************************************************************************************************
		$firstmonth =  $omonth;
		$firstyear =  $oyear1;
		$tmonth = $firstmonth;
		$tyear =  $firstyear;		
		$jobtype = array();
		for ($i=1; $i<=12; $i++) {
			if ($tmonth == 13 ) { 
				$tmonth =  1;
				$tyear = $tyear + 1;
				}
	
			$jobtype[$i][1] = $tmonth;   //1 ==> month
			$jobtype[$i][2] = $tyear;      // 2 ==> Year 
			$jobtype[$i][3] = 0.00;         //  3 ==>  amountpi
			$jobtype[$i][4] = 0.00;        //  4 ==>  amountpo
			$jobtype[$i][5] = 0.00;         //  5 ==>  amountai
			$jobtype[$i][6] = 0.00;         //  6 ==>  amountao
			$tmonth = $tmonth + 1;
			}		
	$sql ="SELECT ProjectCode, year(TransDate), month(TransDate), sum(AmountCash)
				FROM cashflow 
				WHERE TypeCode ='P'  AND TransType='I' AND ProjectCode ='$project' 
				GROUP BY  ProjectCode, year(TransDate), month(TransDate)
				Order by  year(TransDate) ASC, month(TransDate)  ASC ";
	$teblecashpi =mysql_query($sql) or die("Error : $sql".mysql_error());
	$countpi = mysql_num_rows($teblecashpi);
	while($data2 = mysql_fetch_array($teblecashpi)){
			$projectpi =$data2['ProjectCode'];
			 $tyear =  $data2["1"];
			$tmonth =  $data2["2"];
		   $sumamountpi  =  $data2["3"];
			if ($firstyear == $tyear) { $i = ($tmonth - $firstmonth) + 1;}
			if ($firstyear < $tyear) { $i = (12 - $firstmonth)+1 + $tmonth;}	
			$jobtype[$i][3] = $data2["3"];
	}
	
		//**********************************************************************************************************
	$sql ="SELECT ProjectCode, year(TransDate), month(TransDate), sum(AmountCash)
				FROM cashflow 
				WHERE TypeCode ='P'  AND TransType='O' AND ProjectCode ='$project' 
				GROUP BY  ProjectCode, year(TransDate), month(TransDate)
				Order by  year(TransDate) ASC, month(TransDate)  ASC ";
	$teblecashpo =mysql_query($sql) or die("Error : $sql".mysql_error());
	while($data3 = mysql_fetch_array($teblecashpo)){
			$projectpo =$data3['ProjectCode'];
			$tyear =  $data3["1"];
			$tmonth =  $data3["2"];
		   $sumamountpo  =  $data3["3"];
			if ($firstyear == $tyear) { $i = ($tmonth - $firstmonth) + 1;}
			if ($firstyear < $tyear) { $i = (12 - $firstmonth)+1 + $tmonth;}	
			$jobtype[$i][4] = $data3["3"];
	}
	//**********************************************************************************************************
	$sql ="SELECT ProjectCode,year(TransDate),month(TransDate),sum(AmountCash)
				FROM cashflow 
				WHERE TypeCode ='A' AND TransType='I' AND ProjectCode ='$project' AND TaxInvoiceNo <>''
				GROUP BY  ProjectCode, year(TransDate), month(TransDate)
					Order by  year(TransDate) ASC, month(TransDate)  ASC ";
	$teblecash =mysql_query($sql) or die("Error : $sql".mysql_error());
		while($data4 = mysql_fetch_array($teblecash)){
			$projectai =$data4['ProjectCode'];
			$tyear =  $data4["1"];
			$tmonth =  $data4["2"];
		   $sumamountai  =  $data4["3"];
			if ($firstyear == $tyear) { $i = ($tmonth - $firstmonth) + 1;}
			if ($firstyear < $tyear) { $i = (12 - $firstmonth)+1 + $tmonth;}	
			$jobtype[$i][5] = $data4["3"];
	}
		//**********************************************************************************************************
	$sql ="SELECT ProjectCode,  year(TransDate), month(TransDate), sum(AmountCash)
				FROM cashflow 
				WHERE TypeCode ='A' AND TransType='O' AND ProjectCode ='$project' AND TaxInvoiceNo <>''
				GROUP BY  ProjectCode, year(TransDate), month(TransDate)
					Order by  year(TransDate) ASC, month(TransDate)  ASC ";
	$teblecashao =mysql_query($sql) or die("Error : $sql".mysql_error());
		while($data5 = mysql_fetch_array($teblecashao)){
			$projectao =$data5['ProjectCode'];
			$tyear =  $data5["1"];
			$tmonth =  $data5["2"];
		   $sumamountao  =  $data5["3"];
			if ($firstyear == $tyear) { $i = ($tmonth - $firstmonth) + 1;}
			if ($firstyear < $tyear) { $i = (12 - $firstmonth)+1 + $tmonth;}	
			$jobtype[$i][6] = $data5["3"];
		
	}
	
?>
<table width="100%" border="0">
  <tr>
    <td colspan="3" align="center"><strong>ประมาณการกระแสเงินสดเทียบกับกระแสเงินสดของโครงการ&nbsp;</strong></td>
  </tr>
  <tr>
    <td width="25%"><strong><font size="2">ฝ่าย&nbsp; <?= $deptcodeO." ".$depnameO;?>
    </font></strong></td>
     <td width="42%"><strong><font size="2">โครงการ&nbsp;<?= $project." ". $descriptionO;?>
    </font></strong></td>
     <td width="33%"><strong><font size="2">มูลค่าโครงการ&nbsp;<?= number_format($amountO,2);?>&nbsp;บาท(ไม่รวมภาษีมูลค่าเพิ่ม)</font></strong></td>
  </tr>
  </table>
<?php
$g = new Graph(300,250);
$g->SetScale("textlin");
$title=iconv('TIS-620','UTF-8',"ประมาณการกระแสเงินสดเทียบกับกระแสเงินสดของโครงการ");
$g->title->Set($title);
$g->title->SetFont(FF_JASMINE,FS_BOLD,16);
$labels = array("ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย."); 
for ($i =0; $i < count($labels); $i++) {
	$labels[$i] = iconv('TIS-620','UTF-8',$labels[$i]);
}
$g->xaxis->SetTickLabels($labels);
$g->xaxis->SetFONT(FF_CORDIA,FS_NORMAL,14);
$g->xaxis->SetLabelAngle(45);
$data6 = array(300,250,425,300,175,250);
$line1 = new LinePlot($data6);
$data7 = array(150,200,175,300,250,275);
$line2 = new LinePlot($data7);

$line1->value->Show();
$line1->mark->SetType(MARK_FILLEDCIRCLE);
$line1->SetLegend("Product 1");

$line2->value->Show();
$line2->mark->SetType(MARK_SQUARE);
$line2->SetLegend("Product 2");

$g->Add($line1);
$g->Add($line2);
$g->Stroke ();
?>
<?
mysql_close($conn);
?>
<a href="fview_report_cashflow_depart.php?DeptCode=<? echo $deptcodeO;?>">ออก</a>
</body>
</html>





Tag : PHP, MySQL, HTML/CSS, JavaScript, CakePHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-03-14 14:51:10 By : มือใหม่ View : 2470 Reply : 6
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ปกติไฟล์ที่สร้างกราฟจะต้องแยกกันออกมาอีกไฟล์หนึ่งซึ่งเป็น .php น่ะครับ และตอนเรียกก็ให้ใช้ Tag img ครับ

Code (view.php)
<img src="images.php">


Code (images.php)
// code สร้างกราฟ


ลองดูตัวอย่างจาก demo ไฟล์ก็ได้ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-14 15:04:37 By : webmaster
 


 

No. 2

Guest


ถ้าต้องการแทรกใน html ใช้คำสั่ง
http://hem.bredband.net/aditus/chunkhtml/ch10s04.html
ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-14 15:48:13 By : .
 

 

No. 3

Guest


<img src="images.php"> ต้องไปใส่ตรงไหนค่ะ
include("JpGraph<img src=jpgraph.php>"); อย่างนี่หรือป่าวค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-24 23:35:00 By : jub
 


 

No. 4

Guest


ตอบความคิดเห็นที่ : 3 เขียนโดย : jub เมื่อวันที่ 2011-09-24 23:35:00
รายละเอียดของการตอบ ::
... ต้องใส่ tag ใน html เท่านั้น
ไม่เเน่ใจว่ามีวิธีที่จะใส่ใน tag php ได้รึป่าว

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-10-13 00:59:01 By : Adel
 


 

No. 5



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : webmaster เมื่อวันที่ 2011-03-14 15:04:37
รายละเอียดของการตอบ ::
ตามที่พี่วินบอกครับ


ตรงนี้

Code (PHP)
<?php
$g = new Graph(300,250);
$g->SetScale("textlin");
$title=iconv('TIS-620','UTF-8',"ประมาณการกระแสเงินสดเทียบกับกระแสเงินสดของโครงการ");
$g->title->Set($title);
$g->title->SetFont(FF_JASMINE,FS_BOLD,16);
$labels = array("ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย."); 
for ($i =0; $i < count($labels); $i++) {
	$labels[$i] = iconv('TIS-620','UTF-8',$labels[$i]);
}
$g->xaxis->SetTickLabels($labels);
$g->xaxis->SetFONT(FF_CORDIA,FS_NORMAL,14);
$g->xaxis->SetLabelAngle(45);
$data6 = array(300,250,425,300,175,250);
$line1 = new LinePlot($data6);
$data7 = array(150,200,175,300,250,275);
$line2 = new LinePlot($data7);

$line1->value->Show();
$line1->mark->SetType(MARK_FILLEDCIRCLE);
$line1->SetLegend("Product 1");

$line2->value->Show();
$line2->mark->SetType(MARK_SQUARE);
$line2->SetLegend("Product 2");

$g->Add($line1);
$g->Add($line2);
$g->Stroke ();
?>


ให้เอาไปสร้างเป็นไฟล์ แล้วตรงนี้อีกนั้นแหละใส่ <img src="ชื่อไฟล์ที่ copy โค๊ดด้านบนมา.php">

ยังงงอยู่ไหมครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-10-13 06:20:54 By : ikikkok
 


 

No. 6



โพสกระทู้ ( 99 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

แล้วถ้าหากว่า ค่าที่จะเอามาแสดงเป็นกราฟ รับค่ามาจากฟอร์ม ต้องทำไงครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-08-06 15:21:09 By : jackkichan
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : เรียนถามท่านผู้รู้ค่ะ คือดิฉันสร้างกราฟแล้วฟ้อง JpGraph Error: HTTP headers have already been sent.
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่