Exported File is Empty or Database Error Appears

Question:


When I try to export a recordset to a PDF file, the file appears empty or throws an error.

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

The following error is displayed in the CSV, XML or Excel formats:

"Warning:  mysql_num_fields(): 7 is not a valid MySQL result resource in dmxDataExporter.php on line 1159"

instead of the data. What have I done wrong?

Answer:


In Dreamweaver, switch to Code view and make sure that the UDE code bit is after the code that populates the Recordset and before the code that clears the results from the recordset:

mysql_select_db($database_demo, $demo);
$query_Recordset1 = "SELECT * FROM users ORDER BY id ASC";
$Recordset1 = mysql_query($query_Recordset1, $demo) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php
// Universal Data Exporter 1.0.1
// Type: csv
$ude1 = new dmxCSVExporter();
$ude1->fieldSeparator = ",";
$ude1->lineSeparator = "\n";
$ude1->quoteFields = true;
$ude1->includeFieldNames = false;
$ude1->stripHtmlTags = false;
$ude1->fileName = "export";
$ude1->sourceRecordset = $Recordset1;
$ude1->sourceFieldsString = "id,id,50,C,L,fname,fname,50,C,L,lname,lname,50,C,L,email,email,50,C,L,perms,perms,50,C,L";
$ude1->doExport();
?>
<?php
mysql_free_result($Recordset1);
?>