Jump to content

Oppening .dbf file with odbc


Recommended Posts

Hello. I am having problems accessing my dbf files with PHP. I've been searching for a while for a solution, but can't seem to find a working one. Here is my current situation:

 

I have a CentOS Server, in which I've placed my dbf files.

I can open these with dbase functions, but I'm limited to my queries, since I have thousands of records.

I've been trying something similar to this:

 

 

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$data_source = 'DRIVER={Microsoft dBASE Driver (*.dbf)};datasource=/home/dir/file.dbf;';
//$data_source = 'DRIVER={Microsoft dBASE Driver (*.dbf)};DriverID=277;datasource=/home/dir/file.dbf;';
$user='';
$password='';
$conn=odbc_connect($data_source,$user,$password);
if (!$conn)
{
exit("Connection Failed:" . odbc_errormsg() );
}
?>

 

I get the following error output:

Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /home/dir/index.php on line 45

Connection Failed:[unixODBC][Driver Manager]Data source name not found, and no default driver specified

Link to comment
Share on other sites

update:

 

I've been reading alot, and I noticed I had to install unixODBC, easysoft drivers and freetds to manage my ODBC.

Now, I can't seem to find the right drivers to register in my odbcinst.ini, so that I can use them in the odbc.ini file.

 

I should be looking for drivers compatible with dBASE right?

 

Gosh this is getting really troublesome.

 

I think I'll go with another solution. Since I can't seem to make a query like "select * from table where id = 123" with dBASE, because I have multiple dbf files and need to check all the rows. I might dump all the files into a mysql db. So, everytime I need to update the tables, I just press a button, and I'll update the tables... I think this might be the best solution for my problem, since it is kind of urgent.

 

I'de like to hear some feedback,

thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.