1
votes

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.

Method 1: I manage to install the foxpro ODBC driver and create a system DNS, below is my php script and output.

php script:

$odbc = odbc_connect ("myDB", "" , "");
$strsql= "SELECT * FROM icitem WHERE CAT=820";
$query = odbc_exec($odbc, $strsql) or die (odbc_errormsg());
odbc_close($odbc);

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.

Method 2: I install the microsoft ole db provider for visual foxpro 9 at http://www.microsoft.com/en-us/download/details.aspx?id=14839

php script:

$conn = new COM("ADODB.Connection") ;
$conn->Open('Provider=vfpoledb;Data Source=C:\xampp\htdocs\db;
Collating Sequence=machine;');
$query="SELECT * FROM icitem WHERE CAT=820";
$conn->Execute($query);
$conn->Close();

output: Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft OLE DB Provider for Visual FoxPro
Description: 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

Look like both output required the stock.dbc instead of icitem.dbf? I only have the icitem.dbf and icitem.fpt.

1

1 Answers

0
votes

I know this is old but to help others...

I too had this issue. I solved it by using this library: http://adodb.sourceforge.net/