PHP uses PDO to access

Source: Internet
Author: User
In PhP5, PDO is added and unified access is adopted for different databases. It is said that PDO is used for database operations in PhP6 by default.
Access is a frequently used database, which is very convenient for small applications! After searching, but no specific connection method was found, we searched and studied. The following is the method for connecting to access through PDO: Program Code <? PHP
Try {
$ Db = new PDO ("ODBC: Driver = {Microsoft Access Driver (*. mdb)}; DBQ =". Getcwd ()." \\# dB. mdb ");
Echo "connected \ n ";
} Catch (exception $ e ){
Echo "failed:". $ e-> getmessage ();
}
?>

Connection successful! If no, check that the PDO extension is installed. Open PHP. ini and check whether the extension = php_pdo_odbc.dll
If you do not have one, you can call phpinfo () to check whether the extension is correctly installed!
Note that there must be a space in front of the string "(*. mdb)". Many people have made this mistake.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.