title: Fatal error: Uncaught Exception: FPDF error: Some data has already been output, can't send PDF file
body: <p>This is my code:</p>
  
  <pre><code>&lt;?php
  include ("../connections.php");
  require("fpdf181/fpdf.php");
  ob_end_clean();
  ob_start();
  if (isset($_POST["btn_1"])) {
  class PDF extends FPDF{
  
  function Header(){
    global $title;
    $w = $this-&gt;GetStringWidth($title)+6;
    $this-&gt;SetX((210-$w)/2);
    $this-&gt;Image('fpdf181/logo.png',10,6,20);
    $this-&gt;SetFont('Times','B',30);
    $this-&gt;SetLineWidth(1);
    $this-&gt;Cell($w,10,$title,0,0,'C');
    $this-&gt;Ln(20);
  }
  function table(){
  
  }
  function layout(){
  
  
  }
  
  function footer(){
    $this-&gt;SetY(-15);
    $this-&gt;SetFont('Arial','I',8);
    $this-&gt;Cell(0,10,'Page '.$this-&gt;PageNo(),0,0,'C');
  }
  }
  $pdf = new PDF();
  $title = "MONTHLY SALES REPORT";
  $pdf-&gt;SetTitle($title);
  $pdf-&gt;AddPage();
  $pdf-&gt;SetFont('Arial','B',12);
  $pdf-&gt;SetFillColor(180,180,255);
  $pdf-&gt;SetDrawColor(50,50,100);
  $pdf-&gt;Cell(10,10,"Generic Name",1,0,'',true);
  $pdf-&gt;Cell(60,10,'Branded Name',1,0,'',true);
  $pdf-&gt;Cell(60,10,'Unit',1,0,'',true);
  $pdf-&gt;Cell(65,10,'QTY Available',1,0,'',true);
  $pdf-&gt;Ln();
  $view_query = mysqli_query($connections, "SELECT * FROM product");
  while ($row = mysqli_fetch_assoc($view_query))
  {
  
  $db_genericname = $row["genericname"];
  $db_brandedname = $row["brandedname"];
  $db_unit = $row["unit"];
  $db_quantityavailable = $row["quantity_available"];
  
  $pdf-&gt;Cell(10,10,$db_genericname,1);
  $pdf-&gt;Cell(60,10,$db_brandedname,1); 
  $pdf-&gt;Cell(60,10,$db_unit,1); 
  $pdf-&gt;Cell(65,10,$db_quantityavailable,1); 
  $pdf-&gt;Ln();
  }
  $pdf-&gt;Output();
  ob_end_flush();
  }
  ?&gt;
  </code></pre>
  
  <p>This is the error i get: </p>
  
  <blockquote>
    <p>Fatal error: Uncaught Exception: FPDF error: Some data has already
    been output, can't send PDF file (output started at
    C:\xampp\htdocs\SAD\manager\productrecords.php:1) in
    C:\xampp\htdocs\SAD\manager\fpdf181\fpdf.php:271 Stack trace: #0
    C:\xampp\htdocs\SAD\manager\fpdf181\fpdf.php(1052): FPDF->Error('Some
    data has a...') #1 C:\xampp\htdocs\SAD\manager\fpdf181\fpdf.php(999):
    FPDF->_checkoutput() #2
    C:\xampp\htdocs\SAD\manager\productrecords.php(258): FPDF->Output() #3
    {main} thrown in C:\xampp\htdocs\SAD\manager\fpdf181\fpdf.php on line
    271</p>
  </blockquote>
  
  <p>I do know what to do anymore i tried my best searching solutions for this and tried them but to no good. A little help would  be appreciated :)</p>