Ashish Sood Posted February 25, 2014 Share Posted February 25, 2014 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 More sharing options...
Ingolme Posted February 25, 2014 Share Posted February 25, 2014 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 More sharing options...
Ashish Sood Posted February 25, 2014 Author Share Posted February 25, 2014 Thanks for your reply Ingolme I Tried but it did not worked for me, , Could you please explain via example. Link to comment Share on other sites More sharing options...
justsomeguy Posted February 25, 2014 Share Posted February 25, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now