How can we connect a PHP script to MS Access (.mdb) file?
I tried by including following PHP code:
$db_path =
it looks like a problem with the path seperators. ISTR that you have to pass backslashes not forward slashes
The following works for me - with an MDB file in the webroot called db4
$defdir = str_replace("/", "\\", $_SERVER["DOCUMENT_ROOT"]);
$dbq = $defdir . "\\db4.mdb";
if (!file_exists($dbq)) { die("Database file $dbq does not exist"); }
$dsn = "DRIVER=Microsoft Access Driver (*.mdb);UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL=MS Access;DriverId=25;DefaultDir=$defdir;DBQ=$dbq";
$odbc_conn = odbc_connect($dsn,"","")
or die("Could not connect to Access database $dsn");