Jump to content

using FPDF


Ashish Sood

Recommended Posts

Hi All,

 

 

I am using FPDF library, to generate a PDF document, its is my first time i am using it. but getting a error while generating the PDF document.

Notice: Array to string conversion in C:inetpubwwwrootcustomersfpdffpdf.php on line 656FPDF error: Some data has already been output, can't send PDF file

My requirements,

 

I want to fetch a details on per days basis from my table, for that i have created a textbox and button , in which user can entered the date and as per the date i want to generate a PDF file.

 

My Code

<html><body><p>MM/DD/YYYY</p><form action="" method="post">  <input type=text name=search >               //Textbox<input type="submit" name="submit" value="Fetch Report">  //fetch Report button</form></body></html><?phprequire ('fpdf/fpdf.php');$date=date("m/d/Y");                              //Assigning Date to date variableecho "<br>";echo "Today's Date Is = $date";include("../../../../../../../inetpub/wwwroot/dbcon/connection.php");$selectdb=mysql_select_db("customer",$con);if(!$selectdb){      die ("Database Connection Error" .mysql_error());}if(isset($_POST['submit'])){         $selectcondition = "SELECT * from orders_details where DATE='".$_POST['search']."'";     $mydata=mysql_query($selectcondition,$con);     $row=mysql_fetch_assoc($mydata);              $pdf = new FPDF();     $pdf->addPage();     $pdf->SetFont('Arial','B',16);     $pdf->Cell(40,10,$row);     $pdf -> output();    }?>

Please let me know what sort of changes i need to add into it.

 

 

Thanks

Ashish

Link to comment
Share on other sites

It says you can't print anything before outputting PDF data. Move the PDF script to a different file and set the form action to the name of that file. Remove the echo statements as well.

Link to comment
Share on other sites

You're also sending an array to the Cell method. The Cell method expects a string, not an array. That is why PHP is telling you that it is doing array to string conversion. Like Ingolme said, the second error message is because you're outputting a bunch of HTML code for a form before the PDF document. Either output HTML, or a PDF, not both.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...