Skip to content

Instantly share code, notes, and snippets.

@math-alpha
Created April 14, 2020 09:36
Show Gist options
  • Save math-alpha/6e2baa80e0e74f946f2fedea6bad2030 to your computer and use it in GitHub Desktop.
Save math-alpha/6e2baa80e0e74f946f2fedea6bad2030 to your computer and use it in GitHub Desktop.
// connection code
<?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=;");
// sample query code
<?php
$sql = "SELECT price FROM product";
$sql .= " WHERE id = " . $productId;
$result = $db->query($sql);
$row = $result->fetch();
$productPrice = $row["price"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment