PHP Connects Access database code

Source: Internet
Author: User
Tags dsn connect php tutorial table name access database

PHP Tutorial connecting Access database Tutorial code

Here are three kinds of PHP connection Access database methods, one is to use PHP's PDO, one is the Odbc,com interface to connect with the Access database Oh.

*/

Connecting to an Access database with PDO

$path = "F:fontwww.111cn.netspiderresult.mdb";

$conn = new PDO ("SQLite: $path");

if ($conn)

{

Echo (' Connection PDO success ');

}

Else

{

Echo (' Cnnection PDO fail, plase check Database server! ');

}

Connecting a database using Odbc_connect

$conn = Odbc_connect ("Dbdsn", "admin", "123"); Connecting to a data source

$doquery =odbc_exec ($conn, "select * from table name where Condition");//Execute query//Connect Access database with COM interface

$conn =new com ("adodb.connection");

$DSN = "Driver={microsoft Access Driver (*.mdb)};d bq=". Realpath ("Path/db1.mdb");

$conn->open ($DSN);

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.