1
votes

I'm trying to use the dbase library in php5.3 to open a .dbf file. I've got the dbase.so library installed and active on my php5 build and I'm executing the following code:

$db = dbase_open('CMX.dbf', 0);
if( $db ){
    echo 'success';
    dbase_close($db);
}

Where CMX.dbf is a Visual FoxPro9 data table and is located in the same directory as the executing script with read/write/execute permissions enabled.

The following is an exert from /var/log/apache2/error.log:

PHP Warning:  dbase_open(): unable to open database CMX.dbf in /var/www/test.php on 

line 28

As this error/warning is not very descriptive, I'm having issues tracking down the root cause. Can anyone help with this?

3
From the manual, there is not more information available but just that it failed to open the database. Permission and/or file-format comes to mind. - hakre

3 Answers

0
votes

Not positive about PHP, nor Apache, but typically, when trying to connect to database files (or Foxpro), the typical approach would be to have a CONNECTION to a PATH, then perform a query against the name of the table....

0
votes

Try this (in foxpro):

use cmx.dbf
copy to cmx_php.dbf type fox2x

I was having a similar problem where some dbs would open and others would not. This allowed me to access the db with php/dbase.so

I found the info here in the comments section.

-1
votes

Try this:

$db_path = "CMX.dbf";

$db = dbase_open($db_path, 0) // 0=ReadOnly, 1=WriteOnly 2=ReadWrite 
       or die("Error! Could not open dbase database file '$db_path'.");

if( $db ){
    echo 'success';
    dbase_close($db);
}