简体   繁体   中英

php dbase error when opening a .dbf file

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?

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.

对PHP或Apache都不满意,但通常,当尝试连接到数据库文件(或Foxpro)时,典型的方法是将CONNECTION连接到PATH,然后对表名执行查询。

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM