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

PHP method to connect Access using PDO_PHP tutorial

WBOY
Release: 2016-07-20 11:17:51
Original
1393 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template