PHP FPDF errors

I am getting the following errors  when I attempt to produce a pdf.

Warning: Cannot modify header information - headers already sent by (output started at /home/content/t/r/a/transconvalue/html/propinsp.php:7) in /home/content/t/r/a/transconvalue/html/fpdf.php on line 1017
FPDF error: Some data has already been output, can't send PDF file.

From what I have been able to research, the header issue is generally caused by blank spaces, but I can't determine where they are.

I'm at a loss on the some data has already been sent.  Thank you.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rcowen00Author Commented:
I'm sorry, I just realized I didn't enter the code.  Here it is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN http: //">

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Property Inspection Form</title>
		<style type="text/css">
			body {
				background-color: #FFFFFF;
				margin-left: 10%;
				margin-right: 10%;
				border: 2px solid gray;
				padding: 20px 20px 20px 20px;
				font-family: Verdana, Helvetica, Arial, sans-serif;
			table {
				margin-left: 20px;
				margin-right: 20px;
				border: thin solid white;
				caption-side: top;
				background-color: #E6E6FA
			td, th {
                                font-weight: normal; 
                                font-size: 8pt; 
                                color: #000000; 
                                font-family: verdana, arial, helvetica, sans-serif;
                                text-decoration: none;
				border: 2px solid white;
				padding: 5px;
				text-align: left;
			caption {
				padding-top: 8px;
				background-color: #A3C2FF;
<form enctype="multipart/form-data" method="POST" action="<?php echo $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']; ?>">
<div id="nav">
<ul id="headerNav">
<li><a href="index.php" title="index">Home</a></li>
<li><a href="pending.php" title="Pending">Pending</a></li>
<li class="headerRight"><a href="/logout" title="Logout">Logout</a></li>
<div id="?header?">
<h4><b>Instructions to Broker/Agent</b></h4>
<li>Please inspect and complete within 1 business day, unless otherwise agreed upon </li>



                echo 'TC Number:  '. $tc_number .''; 
                echo 'Property Address:  '. $prop_addr_1. '<br />';  
	        echo '  City:  '. $prop_city. '';
                echo '  State:  '. $prop_state. '';
                echo '  Zip:  '. $prop_zip .'<br />';
                echo '  County:  '. $prop_county . '';
     //insert new record to prop_insp
     $query_pir_insert="INSERT INTO prop_insp(job_id,listing_agent,listed_realtor,sale_sign,sale_sign_comm,vandalism,vandalism_comm,health_safe,health_safe_comm,prop_secure,prop_secure_comm,land_main,land_main_comm,electricity,electricity_comm,water,water_comm,int_clean,int_clean_comm,winterized,winterized_comm,listing_office,code_viol,code_viol_comm)
     $result_pir_insert=mysqli_query($dbc,$query_pir_insert) or die('ERROR PIR INSERT');

//update job fields
     $query_job_update="UPDATE job 
                        SET  mls_number='$mls_number',curr_price='$curr_price',prev_price='$prev_price',dt_last_reduc='$dt_last_reduc', mls_location='$mls_location'
                        WHERE job_ID='$job_id'";
     $result_job_update=mysqli_query($dbc,$query_job_update)or die('ERROR JOB UPDATE');


$pdf=new FPDF();
$pdf->Cell(40,10,'Hello World!');
<h2><center>PROPERTY INSPECTION FORM</center></h2>
<p><input value="Upload Photos" name="uploadphoto" type="submit" /><input value="Submit Data" name="submit" type="submit" /><input value="Produce PDF" name="propinsppdf" type="submit" /></p>
<th>Listing Agent Name</th>
<td><input name="listing_agent" type="text" /></td>
<th>Listing Agent Office</th>
<td><input name="listing_office" type="text" /></td>
<th>Is the property currently listed on MLS?</th>
<td><input name="mls_number" type="text" /></td>
<td><input type="file" id="uploadmls" name="uploadmls" /></td>
<th>Is the property currently listed on</th>
<td>Yes<input name="listed_realtor" value="Y" type="radio" /> No<input name="listed_realtor" value="N" type="radio" /></td>
<th>Current Price: </th>
<td><input name="curr_price" type="currency" /></td>
<th>Previous Price: </th>
<td><input name="curr_price" type="currency" /></td>
<th>Date of Last Price Reduction: </th>
<td><input name="dt_last_reduc" type="date" />
<th>Is there a for sale sign visible from the street?</th>
<td>Yes<input name="sale_sign" value="Y" type="radio" /> No<input name="sale_sign" value="N" type="radio" /></td>
<td><textarea name="sale_sign_comm" rows="2" cols="40"></textarea></td>
<th>Are there any signs of vadalism?</th>
<td>Yes<input name="vandalism" value="Y" type="radio" /> No<input name="vandalism" value="N" type="radio" /></td>
<td><textarea name="vandalism_comm" rows="2" cols="40"></textarea></td>
<th>Are there any visible signs of code violations?</th>
<td>Yes<input name="code_viol" value="Y" type="radio" /> No<input name="code_viol" value="N" type="radio" /></td>
<td><textarea name="code_viol_comm" rows="2" cols="40"></textarea></td>
<th>Are there any health and safety issues with the property?</th>
<td>Yes<input name="health_safe" value="Y" type="radio" /> No<input name="health_safe" value="N" type="radio" /></td>
<td><textarea name="health_safe_comm" rows="2" cols="40"></textarea></td>
<th>Is the property secured?</th>
<td>Yes<input name="prop_secure" value="Y" type="radio" /> No<input name="prop_secure" value="N" type="radio" /></td>
<td><textarea name="prop_secure_comm" rows="2" cols="40"></textarea></td>
<th>Is the landscaping maintained?</th>
<td>Yes<input name="land_main" value="Y" type="radio" />No<input name="land_main" value="N" type="radio" /></td>
<td><textarea name="land_main_comm" rows="2" cols="40"></textarea></td>
<th>Is the interior of the property clean?</th>
<td>Yes<input name="int_clean" value="Y" type="radio" /> No<input name="int_clean" value="N" type="radio" /></td>
<td><textarea name="int_clean_comm" rows="2" cols="40"></textarea></td>
<th>Is the electricity turned on?</th>
<td>Yes<input name="electricity" value="Y" type="radio" /> No<input name="electricity" value="N" type="radio" /></td>
<td><textarea name="electricity_comm" rows="2" cols="40"></textarea></td>
<th>Is the water turned on?</th>
<td>Yes<input name="water" value="Y" type="radio" /> No<input name="water" value="N" type="radio" /></td>
<td><textarea name="water_comm" rows="2" cols="40"></textarea></td>
<th>If between September and April, are there notices that the home has been winterized? (please provide photos of notices)?</th>
<td>Yes<input name="winterized" value="Y" type="radio" /> No<input name="winterized" value="N" type="radio" />N/A<input name="winterized" value="na" type="radio" /></td>
<td><textarea name="winterized_comm" rows="2" cols="40"></textarea></td>
<th>Please provide any additional comments, such as, condition of neighboring homes, current real estate market conditions in the area.</th>
<td><textarea name="add_comm" rows="2" cols="40"></textarea></td>
Agent Name: <input name="agent_name" type="text" /> Date Inspection Completed:  <input name="completed_date" type="date" />
<p><input value="Upload Photos" name="uploadphoto" type="submit" /><input value="Submit Data" name="submit" type="submit" /><input value="Produce PDF" name="propinsppdf" type="submit" /></p>

Open in new window

I have not used FPDF yet myself but it looks like you might be submitting a form to the same page...
that you've already output HTML to.

I personally prefer breaking up with process by using a second php action/processing type page...
and that second page is where you put all your php form handling stuff, fpdf, etc -- where everything is within <?php  ?>.

Then when finished processing -- send the user back to the original page (or a third page if you prefer) to show results.

Option 2... would be to do what you're doing but make sure that the first thing you do on the page is your <?php ?> script that checks for the submitted vars and attempts to process them if found.

Note: Make sure there's no other spaces, HTML etc on the page above that initial <?php  ?> block.

Try it and let me know if that didn't fix your issue.

Ray PaseurCommented:
The header issue is caused by ANY browser output at all, so the very first line with the DOCTYPE declaration is the start of the problem - it is browser output.  In other words, the script is misdesigned if you intend to send headers.

My recommendation: Write the PDF to a file and give the client a link to access it.  That way you will not have to rewrite your application - just make a few changes.  HTH, ~Ray

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rcowen00Author Commented:
Thank you
Ray PaseurCommented:
Thanks for the points - it's a great question! ~Ray
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.