title: Php reading Foxpro DBF file
body: <p>I need to do a record search and display in a Foxpro dbf file using PHP. My dbf file name icitem.DBF, i am using ODBC and OLEDB methods but both return errors.</p>
  
  <p>Method 1:
  I manage to install the foxpro ODBC driver and create a system DNS, below is my php script and output.</p>
  
  <p>php script:</p>
  
  <pre><code>$odbc = odbc_connect ("myDB", "" , "");
  $strsql= "SELECT * FROM icitem WHERE CAT=820";
  $query = odbc_exec($odbc, $strsql) or die (odbc_errormsg());
  odbc_close($odbc);
  </code></pre>
  
  <p>output:
  Warning: odbc_exec(): SQL error: [Microsoft][ODBC Visual FoxPro Driver]Cannot open file c:\xampp\htdocs\db\stock.dbc., SQL state S1000 in SQLExecDirect in C:\xampp\htdocs\hottemp\index.php on line 9
  [Microsoft][ODBC Visual FoxPro Driver]Cannot open file c:\xampp\htdocs\db\stock.dbc.</p>
  
  <p>Method 2:
  I install the microsoft ole db provider for visual foxpro 9 at <a href="http://www.microsoft.com/en-us/download/details.aspx?id=14839" rel="nofollow">http://www.microsoft.com/en-us/download/details.aspx?id=14839</a></p>
  
  <p>php script:</p>
  
  <pre><code>$conn = new COM("ADODB.Connection") ;
  $conn-&gt;Open('Provider=vfpoledb;Data Source=C:\xampp\htdocs\db;
  Collating Sequence=machine;');
  $query="SELECT * FROM icitem WHERE CAT=820";
  $conn-&gt;Execute($query);
  $conn-&gt;Close();
  </code></pre>
  
  <p>output:
  Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft OLE DB Provider for Visual FoxPro<br/><b>Description:</b> Cannot open file c:\xampp\htdocs\db\stock.dbc.' in C:\xampp\htdocs\index.php:8 Stack trace: #0 C:\xampp\htdocs\index.php(8): com->Execute('SELECT * FROM i...') #1 {main} thrown in C:\xampp\htdocs\index.php on line 8</p>
  
  <p>Look like both output required the stock.dbc instead of icitem.dbf? I only have the icitem.dbf and icitem.fpt.</p>