title: Crystal Reports 11.5 with PHP and MySQL
body: <p>I am new to Crystal Reports, and I am using version Crystal Reports 11.5.</p>
  
  <p>My requirement is as below:</p>
  
  <ol>
  <li>Programming Environment is PHP .</li>
  <li>Database is MySQL.</li>
  <li>I want to generate PDF reports using Crystal Report + PHP + MySQL.</li>
  </ol>
  
  <p>Currently, I am using COM object to connect to Crystal Report using PHP, and I am able to generate a sample static PDF report.</p>
  
  <p>My main task is to do all processing in PHP by fetching values from MySQL and pass the values to Crystal Reports and generate a PDF. I need assistance to achieve this task. If anybody can provide sample code then it will be much better. </p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>$my_report = "E:\\xampp\\htdocs\\crystal\\Test1.rpt"; 
  
  $my_pdf = "E:\\xampp\\htdocs\\crystal\\test.pdf"; 
  
  $o_CrObjectFactory = new COM('CrystalReports11.ObjectFactory.1');
  
  // Create the Crystal Reports Runtime Application.
  
  
  $o_CrApplication =$o_CrObjectFactory-&gt;CreateObject("CrystalDesignRunTime.Application"); 
  
  //------ Open your rpt file ------ 
  
  $creport = $o_CrApplication-&gt;OpenReport($my_report, 1); 
  
  //------ Connect to DB2 DataBase ------ 
  
  **this is the hard part where I am not able to complete connection to mysql**
  $o_CrApplication-&gt;LogOnServer('which library','mlims','root',''); 
  
  //------ Put the values that you want -------- 
  
  $creport-&gt;RecordSelectionFormula="{parameter.id}='1'"; 
  
  //------ This is very important. DiscardSavedData make a 
  
  // Refresh in your data -------
  
  $creport-&gt;DiscardSavedData; 
  
  //------ Read the records :-P ------- 
  
  $creport-&gt;ReadRecords(); 
  
  //------ Export to PDF ------- 
  
  $creport-&gt;ExportOptions-&gt;DiskFileName=$my_pdf; 
  $creport-&gt;ExportOptions-&gt;FormatType=31; 
  $creport-&gt;ExportOptions-&gt;DestinationType=1; 
  $creport-&gt;Export(false); 
  
  //------ Release the variables 
  $creport = null; 
  $crapp = null; 
  $ObjectFactory = null; 
  </code></pre>
  
  <p>As you see In the above code, I need to connect the Mysql server which I have been trying to do for the last few days. I have tried many examples on the net, but most of them are for SQL Server, not MySQL.</p>