I'm running WAMP 2.5 with PHP 5.5.12. I'm trying to use odbc_connect
to connect to a FoxPro database and eventually query for certain records. But then I realized that dbase
is no longer maintained which would of allowed me to access the records for dbf databases. So I tried using ODBC
with this code:
<?php
$dsn = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=C:\wamp\www\chartnames.dbf;Exclusive=NO;collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;";
$conn = odbc_connect($dsn, "", "");
if (!$conn)
exit("Connection Failed: " .$conn );
//select rows
$rs = odbc_exec($conn, 'SELECT * FROM chartnames');
//display the results
$string = odbc_result_all($rs);
?>
But when I run this code I get an error message:
If you can't read the error is says this:
Warning:odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Driver does not support this function, SQL state IM001 in SQL Connect
I looked up ODBC on php.net I found that only certain databases are supported by the Unified ODBC functions: Adabas D
, IBM DB2
, iODBC
, Solid
, and Sybase SQL Anywhere
.
Is it possible to connect and query a .dbf
FoxPro table with the new versions of PHP? or
Thank you in advance.
UPDATE:
I know that the ODBC driver is no longer supported so they offer OLEDB. I found the OLEDB connection string from here. So I tried replacing the $dsn
variable with this connection string: Provider=vfpoledb.1;Data Source=c:\directory\demo.dbc;Collating Sequence=machine
but I get the same error as stated above. What gives?