|
 |
|
FPDF error: Some data has already been output, can't send PDF file ---> รบกวนช่วยแก้ไขด้วยครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<? ob_start(); ?>
<html>
<head>
</head>
<body>
<?php
//--------------------------- call function --------------------------
require('../pdf/fpdf.php');
require('../includes/db_connect.php');
define('FPDF_FONTPATH','font/');
//--------------------------- start all function --------------------------
function thaiDate($datetime) //--- 12 ธันวาคม 2555
{
list($date,$time) = split(' ',$datetime);
list($H,$i,$s) = split(':',$time);
list($Y,$m,$d) = split('-',$date);
$Y = $Y+543;
switch($m)
{
case "01": $m = "มกราคม"; break;
case "02": $m = "กุมภาพันธ์"; break;
case "03": $m = "มีนาคม"; break;
case "04": $m = "เมษายน"; break;
case "05": $m = "พฤษภาคม"; break;
case "06": $m = "มิถุนายน"; break;
case "07": $m = "กรกฎาคม"; break;
case "08": $m = "สิงหาคม"; break;
case "09": $m = "กันยายน"; break;
case "10": $m = "ตุลาคม"; break;
case "11": $m = "พฤศจิกายน"; break;
case "12": $m = "ธันวาคม"; break;
}
return $d." ".$m." ".$Y;
}
function thaiDate1($datetime) //--- 12/12/2555
{
list($date,$time) = split(' ',$datetime);
list($H,$i,$s) = split(':',$time);
list($Y,$m,$d) = split('-',$date);
$Y = $Y+543;
return $d."/".$m."/".$Y;
}
//--------------------------- end all function --------------------------
?>
<?php
$sql = "select *
from shareholder , prorate
where shareholder.Account_ID = prorate.Account_ID
ORDER BY prorate.Account_ID ASC ";
$query = mysql_query($sql);
?>
<?php
$year = (date("Y")+543); //--- แปลงปีให้เป็น พ.ศ.
$Wide = 6; //--- กำหนดช่วงการเว้นบรรทัด
$pdf = new FPDF();
while( $objResult = mysql_fetch_array($query) )
{
if($objResult["q_share_return"] != 0)
{
$pdf->AddPage();
$pdf->AddFont('dill','','dill.php');
$pdf->SetFont('dill','',14);
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620','ที่ N-Park S '.$objResult["letter_no"].'/'.$year),0,1);
$pdf->Cell(127,$Wide,iconv( 'UTF-8','TIS-620',thaiDate($objResult["date_letter"])),0,1,"R");
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620','เรื่อง ของแจ้งการจัดสรรหุ้นสามัญเพิ่มทุน'),0,1);
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620','เรียน '.$objResult["n_title"].$objResult["n_first"]." ".$objResult["n_last"]),0,1);
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620',' '.$objResult["a_holder"]),0,1);
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620',' --- ที่อยู่ ---'),0,1);
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620',' --- ที่อยู่ ---'),0,1);
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$data = "โดยหนังสือนี้ บริษัทขอแจ้งผลการจัดสรรหุ้นสามัญเพิ่มทุนในส่วนที่ท่านได้จองซื้อเกินสิทธิให้ทราบว่าท่านได้รับการจัดสรรจำนวน ".number_format($objResult["q_share_new"])." หุ้น ดังนั้น บริษัทจึงขอคืนเงินส่วนที่เหลืออีกจำนวน " .number_format($objResult["q_share_return"],2)." บาท เป็นเช็คของธนาคาร ยูโอบี สาขาสำนักงานใหญ่ เช็คเลขที่ ".$objResult["cq_no"]." ลงวันที่ ".thaiDate1($objResult["date_cq"])." มายังท่านพร้อมหนังสือฉบับนี้แล้ว ";
$pdf->MultiCell(0,$Wide,iconv( 'UTF-8','TIS-620',' '.$data),0,1,"");
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->MultiCell(0,$Wide,iconv( 'UTF-8','TIS-620',' '.'จึงเรียนมาเพื่อทราบ'),0,1);
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(130,$Wide,iconv( 'UTF-8','TIS-620','ขอแสดงความนับถือ'),0,1,"R");
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(142,$Wide,iconv( 'UTF-8','TIS-620','บริษัท แนเชอรัล พาร์ค จำกัด (มหาชน)'),0,1,"R");
}
}
$pdf->Output();
?>
</body>
</html>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2012-06-09 14:44:05 |
By :
fiet |
View :
1532 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?ob_start();?>
<html>
<head>
</head>
<body>
ลองดูพวก UTF-8

ตรวจสอบ Output บรรทัดแทรก ๆ ไม่ควรส่งค่า header อย่างอื่นไปก่อน output เช่นพวก <html> หรือจะลองใช้ <?ob_start();?> ไว้บนสุด
|
 |
 |
 |
 |
Date :
2012-06-09 20:13:02 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแล้วครับ แต่ยังเป็นอย่างเหมือนเดิมครับ
ขอบคุณครับ สำหรับคำแนะนำ
|
 |
 |
 |
 |
Date :
2012-06-09 21:17:18 |
By :
fiet |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ mr.win ครับ ขอบคุณสำหรับคำแนะนำครับ
ผลที่ได้คือ
FPDF error: Some data has already been output, can't send PDF file (output started at C:\AppServ\www\npark\report\report_pdf3.php:68)
Code (PHP)
<?php
//--------------------------- call function --------------------------
require('../pdf/fpdf.php');
require('../includes/db_connect.php');
define('FPDF_FONTPATH','font/');
//--------------------------- start all function --------------------------
function thaiDate($datetime) //--- 12 ธันวาคม 2555
{
list($date,$time) = split(' ',$datetime);
list($H,$i,$s) = split(':',$time);
list($Y,$m,$d) = split('-',$date);
$Y = $Y+543;
switch($m)
{
case "01": $m = "มกราคม"; break;
case "02": $m = "กุมภาพันธ์"; break;
case "03": $m = "มีนาคม"; break;
case "04": $m = "เมษายน"; break;
case "05": $m = "พฤษภาคม"; break;
case "06": $m = "มิถุนายน"; break;
case "07": $m = "กรกฎาคม"; break;
case "08": $m = "สิงหาคม"; break;
case "09": $m = "กันยายน"; break;
case "10": $m = "ตุลาคม"; break;
case "11": $m = "พฤศจิกายน"; break;
case "12": $m = "ธันวาคม"; break;
}
return $d." ".$m." ".$Y;
}
function thaiDate1($datetime) //--- 12/12/2555
{
list($date,$time) = split(' ',$datetime);
list($H,$i,$s) = split(':',$time);
list($Y,$m,$d) = split('-',$date);
$Y = $Y+543;
return $d."/".$m."/".$Y;
}
function address($string) //--- address
{
$string = str_replace('ถ.' , '<br />ถ.' , $string);
$string = str_replace('ถ .' , '<br />ถ.' , $string);
$string = str_replace('ถนน' , '<br />ถนน' , $string);
$string = str_replace('เขต' , '<br />เขต' , $string);
$string = str_replace('อ.' , '<br />อ.' , $string);
$string = str_replace('อำเภอ' , '<br />อำเภอ' , $string);
return $string;
}
//--------------------------- end all function --------------------------
?>
<?php
$sql = "select *
from shareholder , prorate
where shareholder.Account_ID = prorate.Account_ID
ORDER BY prorate.Account_ID ASC ";
$query = mysql_query($sql);
?>
<?php
$year = (date("Y")+543); //--- แปลงปีให้เป็น พ.ศ.
$Wide = 6; //--- กำหนดช่วงการเว้นบรรทัด
$pdf = new FPDF();
while( $objResult = mysql_fetch_array($query) )
{
if($objResult["q_share_return"] != "")
{
// $string = $objResult["a_holder"]." ".$objResult["i_zip"];
// $string = str_replace('ถ.' , '<br />ถ.' , $string);
// $string = str_replace('ถนน' , '<br />ถนน' , $string);
// $string = str_replace('เขต' , '<br />เขต' , $string);
// echo $thaiDate1($objResult["date_cq"]) ,'<br /><br />';
echo address($objResult["a_holder"]." ".$objResult["i_zip"]),'<br /><br />';
$pdf->AddPage();
$pdf->AddFont('dill','','dill.php');
$pdf->SetFont('dill','',14);
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620','ที่ N-Park S '.$objResult["letter_no"].'/'.$year),0,1);
$pdf->Cell(127,$Wide,iconv( 'UTF-8','TIS-620',thaiDate($objResult["date_letter"])),0,1,"R");
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620','เรื่อง ของแจ้งการจัดสรรหุ้นสามัญเพิ่มทุน'),0,1);
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620','เรียน '.$objResult["n_title"].$objResult["n_first"]." ".$objResult["n_last"]),0,1);
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620',' '.address($objResult["a_holder"]." ".$objResult["i_zip"])),0,1);
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620',' --- ที่อยู่ ---'),0,1);
$pdf->Cell(0,$Wide,iconv( 'UTF-8','TIS-620',' --- ที่อยู่ ---'),0,1);
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$data = "โดยหนังสือนี้ บริษัทขอแจ้งผลการจัดสรรหุ้นสามัญเพิ่มทุนในส่วนที่ท่านได้จองซื้อเกินสิทธิให้ทราบว่าท่านได้รับการจัดสรรจำนวน ".number_format($objResult["q_share_new"])." หุ้น ดังนั้น บริษัทจึงขอคืนเงินส่วนที่เหลืออีกจำนวน " .number_format($objResult["q_share_return"],2)." บาท เป็นเช็คของธนาคาร ยูโอบี สาขาสำนักงานใหญ่ เช็คเลขที่ ".$objResult["cq_no"]." ลงวันที่ ".thaiDate1($objResult["date_cq"])." มายังท่านพร้อมหนังสือฉบับนี้แล้ว ";
$pdf->MultiCell(0,$Wide,iconv( 'UTF-8','TIS-620',' '.$data),0,1,"");
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->MultiCell(0,$Wide,iconv( 'UTF-8','TIS-620',' '.'จึงเรียนมาเพื่อทราบ'),0,1);
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(130,$Wide,iconv( 'UTF-8','TIS-620','ขอแสดงความนับถือ'),0,1,"R");
$pdf->Cell(0,$Wide,'',0,1); //--- เว้นบรรทัด
$pdf->Cell(142,$Wide,iconv( 'UTF-8','TIS-620','บริษัท แนเชอรัล พาร์ค จำกัด (มหาชน)'),0,1,"R");
}
}
$pdf->Output();
?>
|
 |
 |
 |
 |
Date :
2012-06-10 10:13:51 |
By :
fiet |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|