-1

I am using PHP 7.2.18. I want to establish a database connection with MS Access.

  <?php
ini_set('display_errors','On');
$conn = odbc_connect('access_dbname','','');
if ($conn) {
    echo 'success';
} else {
    echo 'false';
}
?>

When I run it, I get the error as undefined function odbc_connect(). I have tried repeatedly enabling odbc extension in php.ini file but didn't work. Also I am using wamp server.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • 1
    Did you kill and restart your wamp server? Changes to php.ini generally don't take effect until the webserver is restarted. Beyond that, try bringing up a `phpinfo()` page and see if it is available/enabled there. – Tim Lewis Aug 06 '20 at 19:09
  • Yes I tried restarting the server after making changes to php.ini but still I found no odbc driver in phpinfo(). – Muhammad Ahmad Tariq Aug 07 '20 at 04:26

1 Answers1

-1

Since WAMP is a Windows installation, you will need to grab the php_odbc.dll file from somewhere and throw it into your PHP install directory. Then you can change the ini file and restart the server.

You can download it from here: https://www.pconlife.com/viewfileinfo/php-odbc-dll/

Zachucks
  • 158
  • 14
  • php_odbc.dll file is already there in the PHP install directory but its not working. – Muhammad Ahmad Tariq Aug 07 '20 at 04:28
  • did you stop the server, change the ini then start it again? or did you change the ini while the server was running? – Zachucks Aug 07 '20 at 11:11
  • I got the solution by uninstalling the wamp server and installing the xampp. I edited the php.ini file and enabled odbc extension there. Then I restarted the apache server and it worked. Thanks a lot. – Muhammad Ahmad Tariq Aug 08 '20 at 10:12