title: FPDF/PHP - How to generate a pdf file in php using FPDF?
body: <p>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. </p>
  
  <pre><code> &lt;?php
  
      require("fpdf/fpdf.php");
      $pdf = new FPDF();
      global $DB;
      $orderID=$_REQUEST['garID'];
      $sql = "SELECT * FROM `" . $DB-&gt;pre . "garorder` WHERE garID= '" . $orderID . "'"; 
      $d = $DB-&gt;dbRow($sql);
      echo 'name:'.$d['orderdate'].' Party Code :'.$d['partyCode'];
  
      $pdf-&gt;AddPage();
  
              $pdf-&gt;Rect(5, 5, 200, 287, 'D');
  
  
               $pdf-&gt;Cell(10);
               $pdf-&gt;SetFont("Arial","B","8");
               $pdf-&gt;SetXY (10,30);
               $pdf-&gt;MultiCell(50,5,"  ",1,1);
  
      $pdf-&gt;Ln(); 
  
            $pdf-&gt;SetFont('helvetica','B',10);
            $pdf-&gt;Cell(190,7,'Order Details',1,2,'C');
            $pdf-&gt;SetFont('helvetica','',10);
            $y= $pdf-&gt;GetY();
            $pdf-&gt;MultiCell(95,8, "Garment ID: "."\nParty Code: "."\nOrder Date: " , 'LRB',1 );
            //$x= $pdf-&gt;GetX();
            //$pdf-&gt;setXY($x+95,$y);
            $pdf-&gt;Cell(90);
            $pdf-&gt;SetFont('helvetica','',10);
           $pdf-&gt;SetXY (105,62);
            $pdf-&gt;MultiCell(95,12, "Name: "."\nDelivery Status: " , 'LRB',1 );
        $pdf-&gt; Ln();
           $pdf-&gt;Cell(32,10,'Material Description',1,0,'L',0);
           $period = 50;
           for($x=36;$x &lt;=$period; $x=$x+2){
  
             $pdf-&gt;Cell(20,10,$x,1,0,'L',0);  
  
  
  
           }
  
  
      $pdf-&gt;Output();
  
  
      ?&gt;
  </code></pre>