Home  >  Article  >  Backend Development  >  PHP method to connect Access using PDO_PHP tutorial

PHP method to connect Access using PDO_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:17:511330browse

try{

$db = new PDO("odbc:driver={microsoft access driver (*.mdb)};dbq=".getcwd()."#db.mdb");

echo "Connectedn";

 } catch (Exception $e) {

echo "Failed:".$e->getMessage();

 }

The connection is successful! If not, please confirm that the PDO extension has been installed, open php.ini and check if there is such a sentence: extension=php_pdo_odbc.dll

If not, add it yourself. You can call phpinfo() to check whether the extension is installed correctly!

If there is anything in the red box in the picture, it is installed correctly.

There is a small note here. There must be a space in front of the string "(*.mdb)",

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371878.htmlTechArticletry{ $db = new PDO(odbc:driver={microsoft access driver (*.mdb)};dbq =.getcwd().#db.mdb); echo Connectedn; } catch (Exception $e) { echo Failed:.$e-getMessage(); } Connection successful! If...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn