For my uni project I have to connect a website and a Access database
From my computer at home I managed to connect to and query the database
the database is called projectdb and the fields that I queried in that database are Description, Brand and Price
Now when i try and run this coding on the University computers it doesnt work, I get this error message: -
Fatal error: Cannot instantiate non-existent class: com in /spare/apache/htdocs/stud/c0251778/connect.php on line 11
the stud and c0251778 is just my student ID
This is the PHP coding used: -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>DSN-Less Example</title>
<meta http-equiv="Content-Type" content="text/html; ISO-8859-1">
</head>
<body>
<p>
<?php
if (!$conn = new COM("ADODB.Connection"))
exit("Unable to create an ADODB connection<br>");
$strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("c:\projectdb.mdb");
$conn->open($strConn);
$strSQL = "SELECT Description, Brand, Price FROM products";
$rs = $conn->execute($strSQL);
$desc = $rs->Fields(0);
$brand = $rs->Fields(1);
$price = $rs->Fields(2);
print "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">";
print "<tr><td><b>Description</b></td><td><b>Brand</b></td><td><b>Price</b></td></tr>";
while (!$rs->EOF)
{
print "<tr><td>$desc->value</td>";
print "<td>$brand->value</td>";
print "<td>$price->value</td></tr>";
$rs->MoveNext();
}
print "</table>";
// Tidy up
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
</body>
</html>
any help would be much appreciated 🙂