I'm trying to generate a pdf file in a php code using fpdf. However when I'm running this code in the project, this is the output I get: FPDF error: Some data has already been output, can't send PDF file (output started at C:\xampp\htdocs\header.php:92). header.php is not the file in which this script is written. I tried using ob_clean(); and ob_end_flush();. But it doesn't work.
<?php
require("fpdf/fpdf.php");
$pdf = new FPDF();
global $DB;
$orderID=$_REQUEST['garID'];
$sql = "SELECT * FROM `" . $DB->pre . "garorder` WHERE garID= '" . $orderID . "'";
$d = $DB->dbRow($sql);
echo 'name:'.$d['orderdate'].' Party Code :'.$d['partyCode'];
$pdf->AddPage();
$pdf->Rect(5, 5, 200, 287, 'D');
$pdf->Cell(10);
$pdf->SetFont("Arial","B","8");
$pdf->SetXY (10,30);
$pdf->MultiCell(50,5," ",1,1);
$pdf->Ln();
$pdf->SetFont('helvetica','B',10);
$pdf->Cell(190,7,'Order Details',1,2,'C');
$pdf->SetFont('helvetica','',10);
$y= $pdf->GetY();
$pdf->MultiCell(95,8, "Garment ID: "."\nParty Code: "."\nOrder Date: " , 'LRB',1 );
//$x= $pdf->GetX();
//$pdf->setXY($x+95,$y);
$pdf->Cell(90);
$pdf->SetFont('helvetica','',10);
$pdf->SetXY (105,62);
$pdf->MultiCell(95,12, "Name: "."\nDelivery Status: " , 'LRB',1 );
$pdf-> Ln();
$pdf->Cell(32,10,'Material Description',1,0,'L',0);
$period = 50;
for($x=36;$x <=$period; $x=$x+2){
$pdf->Cell(20,10,$x,1,0,'L',0);
}
$pdf->Output();
?>