andrew850101 0 Newbie Poster

Hi! I'm having a problem when generating a crystal report from php. This code works fine when not using connections to ODBC, but when I try to connect i get the error: "Server has not yet been openned". I've tried almost everything, even chaging the dlls but nothing has worked already!

I'm working with crystal reports 8.5, SQL server 2005 through DSN.

Any help is truly appreciated

<?php

$COM_Object = "CrystalRunTime.Application";
$my_report = "C:\\test_dat.rpt";
$my_pdf = "C:\\test.pdf";

$crapp= New COM($COM_Object) or die("Unable to Create Object");
$creport = $crapp->OpenReport($my_report, 1);

$creport->ExportOptions->DiskFileName=$my_pdf;
$creport->ExportOptions->PDFExportAllPages=true;
$creport->ExportOptions->DestinationType=1; // Export to File
$creport->ExportOptions->FormatType=31; // Type: PDF

$creport->ReadRecords();

$creport->Export(false);



/* Format Types:

4 - RTF
31 - PDF
30 - xls
36 - xls
14 - doc

*/
?>