MS Access


How do I connect to MSAccess using PHP?
DSN s connection

<?php
$dbName = $_SERVER["DOCUMENT_ROOT"] . "products\\products.mdb";
if (!file_exists($dbName)) {
die("Could not find database file.");
}
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName; Uid=; Pwd=;");
?php>


DSN-less Connections with ODBC

if (!isset($con))
{ $dbfilename = "C:/Domains/yourwebsite.com/wwwroot/DBfilename.mdb";
$dbuser = "";
$dbpassword = "";
$con = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$dbfilename", $dbuser, $dbpassword);
}

Another Style

You can adapt these samples which require the ADOdb library (which you can download from sourceforge). http://adodb.sourceforge.net/

$db = ADONewConnection('access');
$dsn =
"Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\inetpub\adodb\northwind.mdb;Uid=Admin;Pwd=;";
$db->Connect($dsn);