Jump to content

Recommended Posts

I have two sites one for testing and one is the live site.

on the testing site everything works fine but one the live site I get this error

FPDF error: Some data has already been output, can't send PDF file

What I don't understand is that it is the same code on both sites

Here is the pdf page

<?php
  session_start();
  $refer = $_SESSION['ref'];
  include 'includes/conn_db.php';
  $query_cl = "SELECT * from config";
$result_cl = mysql_query($query_cl, $conn);
while ($row_cl = mysql_fetch_assoc($result_cl)){
$client_name_out = $row_cl["client_name"];
$address_out = $row_cl["address"];
$suburb_out = $row_cl["suburb"];
$city_out = $row_cl["city"];
$postal_address_out = $row_cl["postal_address"];
$postal_code_out = $row_cl["postal_code"];
$tel_out = $row_cl["tel"];
$fax_out = $row_cl["fax"];
$vat_no_out = $row_cl["vat_no"];
$mail_out = $row_cl["mail"];
$url_out = $row_cl["url"];
$image_out = $row_cl["image"];
}
$query_name = "SELECT * from orders WHERE ref_no = '$refer'";
$result_name = mysql_query($query_name, $conn);
while ($row_name = mysql_fetch_assoc($result_name)){
$client_id_out = $row_name["client_id"];
$cl_order_out = $row_name["cl_order"];
$sub_total_out =  $row_name["sub_total"];
$postage_out =  $row_name["postage"];
$vat_out =  $row_name["vat"];
$total_out =  $row_name["total"];
$order_date_out =  $row_name["order_date"];
$final_cl_order = 'Your Order No. ' . $cl_order_out;
}
$query_client = "SELECT * from clients WHERE client_id = '$client_id_out'";
$result_client = mysql_query($query_client, $conn);
while ($row_client = mysql_fetch_assoc($result_client)){
$company_out = $row_client["company"];
$type_of_bus_out = $row_client["type_of_bus"];
$bus_reg_no_out = $row_client["bus_reg_no"];
$bus_vat_no_out = $row_client["bus_vat_no"];
$deladd1_out = $row_client["deladd1"];
$deladd2_out = $row_client["deladd2"];
$del_suburb_out = $row_client["del_suburb"];
$del_city_out = $row_client["del_city"];
$del_province_out = $row_client["del_province"];
$del_code_out = $row_client["del_code"];
$tel_out = $row_client["tel"];
$fax_out = $row_client["fax"];
$email_out = $row_client["email"];
$price_group_out = $row_client["price_group"];
}
$fullname = $firstname_out . " " . $surname_out;
$order_no_final = 'ORDER No. ' . $refer;
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$pdf->cell(50,60,'',0,1,'C');
$pdf->SetFont('Arial','',10);
$pdf->settextcolor(0,0,0);
$pdf->SetFont('Arial','',10);
$pdf->Image('images/logo_order.jpg',2,2,0,0,'','');
$pdf->text(15,32,$company_out,0,0);
$pdf->text(15,36,$deladd1_out,0,0);
$pdf->text(15,40,$deladd2_out,0,0);
$pdf->text(15,44,$del_suburb_out,0,0);
$pdf->text(15,48,$del_city_out,0,0);
$pdf->text(15,52,$del_province_out,0,0);
$pdf->text(15,56,$tel_out,0,0);
$pdf->text(15,65,$order_date_out,0,0);
$pdf->SetFont('Arial','B',10);
$pdf->SetFont('Arial','',10);
$pdf->text(150,36,'P. O. Box 82168',0,0);
$pdf->text(150,40,'Southdale',0,0);
$pdf->text(150,44,'Johannesburg',0,0);
$pdf->text(150,52,'2135',0,0);
$pdf->SetFont('Arial','B',14);
$pdf->text(80,40,$order_no_final,0,1,0);
$pdf->text(80,50,$final_cl_order,0,1,0);
$pdf->SetFont('Arial','',10);
$pdf->SetFillColor(255,255,255);
$pdf->settextcolor(0,0,0);
$pdf->cell(10,5,'Qty',1,'','C',1,'');
$pdf->cell(30,5,'Code',1,'','C',1,'');
$pdf->cell(100,5,'Product',1,'','C',1,'');
$pdf->cell(20,5,'Unit Price',1,'','C',1,'');
$pdf->cell(25,5,'Line Total',1,'1','C',1,'');
$query = "SELECT * from line_items WHERE ref_no = '$refer'";
$result = mysql_query($query, $conn);
while ($row = mysql_fetch_assoc($result)){
$prod_id_out = $row["prod_code"];
$qty_out = $row["qty"];
$date_out = $row["date"];
$query1 = "SELECT * from products WHERE prod_id =  '$prod_id_out'";
$result1 = mysql_query($query1, $conn);
while ($row1 = mysql_fetch_assoc($result1)){
$prod_code_out = $row1["prod_code"];
$prod_name_out = $row1["prod_desc"];
if ($price_group_out == 1) {
      $unit_cost_out = $row1['price1'];
      }
      if ($price_group_out == 2) {
      $unit_cost_out = $row1['price2'];
      }
      if ($price_group_out == 3) {
      $unit_cost_out = $row1['price3'];
      }
      if ($price_group_out == 4) {
      $unit_cost_out = $row1['price4'];
      }
      if ($price_group_out == 5) {
      $unit_cost_out = $row1['price5'];
      }
$list_cost = $unit_cost_out;
  }
$lt = $list_cost * $qty_out;
$lt = number_format($lt, 2, '.', '');
$pdf->SetFont('Arial','B',9);
$pdf->cell(10,5,$qty_out,'RTLB','','C',1,'');
$pdf->cell(30,5,$prod_code_out,'RTLB','','C',1,'');
$pdf->cell(100,5,$prod_name_out,'RTLB','','L',1,'');
$pdf->cell(20,5,$list_cost,'RTLB','','R',1,'');
$pdf->cell(25,5,$lt,'RTLB','1','R',1,'');
}
$pdf->SetFont('Arial','B',10);
$pdf->cell(160,5,'Subtotal',T,'','R',1,'');
$pdf->cell(25,5,$sub_total_out,'1',1,'R',1,'');
$pdf->cell(160,5,'Postage',0,'','R',1,'');
$pdf->cell(25,5,$postage_out,'1',1,'R',1,'');
$pdf->cell(160,5,'VAT',0,'','R',1,'');
$pdf->cell(25,5,$vat_out,'1',1,'R',1,'');
$pdf->cell(160,5,'Total',0,'','R',1,'');
$pdf->cell(25,5,$total_out,'1','1','R',1,'');
$pdf->cell(100,10,'',0,1,'L');
$pdf->cell(100,10,'Authorized By: ',0,1,'L');
$pdf->Output();
?>

Link to comment
https://forums.phpfreaks.com/topic/127529-pdf-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.