I am trying to create a report from PHP using Crystal Reports. The code seems to be correct:
<?php set_time_limit(0); if(isset($_GET['id'])) { $id = $_GET['id']; } else { die('Please specify an ID'); } $path = "c:\\wamp\\www\\billing\\reports"; $file = $chemin."\\bill_".$id.".pdf"; $app_obj = new COM("CrystalRuntime.Application") or Die ("Did not open"); $report= $path."\\bill.rpt"; $rpt_obj= $app_obj->OpenReport($report,1); $app_obj->LogOnServer("p2ssql.dll","host","bdd","userbd","passwordbd"); $rpt_obj->EnableParameterPrompting = FALSE; $rpt_obj->RecordSelectionFormula = "{F_DOCLIGNE.DO_Piece}='$id'"; $rpt_obj->ExportOptions->DiskFileName = $file; $rpt_obj->ExportOptions->PDFExportAllPages = true; $rpt_obj->ExportOptions->DestinationType = 1; $rpt_obj->ExportOptions->FormatType = 31; $rpt_obj->Export(false); header("Content-Type: application/pdf"); readfile($file); ?>
If I run the script from the command line, it works fine, and I exported and parsed the PDF in the console.
But from the point of view of the browser, the story is different. If you get a request through Apache, I get this exception:
com_exception: Source: Crystal Reports ActiveX Designer Details : IM002:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified in C:\wamp\www\facture\report.php on line 25
In the report, the database connection is done through ODBC, I could not use it, because any other driver marked with ODBC refused to work.
source share