1
Good afternoon, you guys!
I’m having a lot of headaches to connect my code to a file .dbf
, and found no solution after running the internet for two days in a row...
This is the code on PHP
<?php
$connection = 'odbc:DRIVER={Microsoft dBase Driver (*.dbf)};DefaultDir=C:\;Exclusive=NO';
$pdo = new PDO($connection);
I’ve already set up the data source:
I enabled the drivers extension=pdo_odbc
and extension=odbc
in the php.ini
Once all this is done, by running the algorithm it returns a:
Fatal error: in C: xampp htdocs Darkness action lerdbf.php on line 5
But, when opening the error log of Apache
, he shows it:
[Wed Jul 17 17:52:33.530567 2019] [php7:error] [pid 1660:tid 1960] [client ::1:51411] PHP Fatal error: Uncaught Pdoexception: SQLSTATE[IM002] Sqldriverconnect: 0 [Microsoft][ODBC Driver Manager] Name of the n xe3o data source found and no xe3o driver specified in C:xampp htdocs Darkness action lerdbf.php:5 nStack trace: n#0 C: xampp htdocs Darkness action lerdbf.php(5): PDO->__Construct('odbc:DRIVER={Mi...') n#1 {main} n thrown in C: xampp htdocs Darkness action lerdbf.php on line 5
I don’t know if the solution is easy or difficult, but this code works on other machines with the same operating system (Windows 10), same version of Apache
and of PHP
... I don’t know what else to try.
In the documentation PDO_ODBC is informing that the library
php_pdo_odbc.dll
shall be empowered tophp.ini
, as you did, thus allowing PHP to connect to any data bank cataloged as DNS SYSTEM. In the photo to realize that your database is cataloged as user DNS.– Augusto Vasques
Augusto, I did the same procedure to catalog as DSN System, and even so does not work...
– Bruno Henrique
I who made you
extension=pdo_odbc
andextension=odbc
, but theextension=php_pdo.dll
added it in php ini? And checked for php_pdo.dll?– Augusto Vasques
Augusto, I researched about this extension because I don’t have it here, and I saw that I should have come by default with PHP... I can’t find a reliable source to download this dll for PHP version 7.3.7... Know a source?
– Bruno Henrique
I do not recommend this type of procedure to anyone for security reasons. I recommend either reinstalling the version or upgrading.
– Augusto Vasques
Augusto, thanks for the answers, but I had to find another solution... I followed the contribution note in the PHP dbase manual, and it was much easier rs https://www.php.net/manual/en/book.dbase.php
– Bruno Henrique