Hi All,
I am trying to connect to a ms access database using
php (long story).
Anyways, when I run the code I get an error "Cannot open with Jet"
Heres is my code :
- Code: Select all
<?php
//$db = 'C:\\Program Files\\Microsoft Office\\Office\\Samples\\Northwind.mdb';
$db = 'C:\\wamp\\www\\work\\access\\pokernews.mdb';
$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
// Two ways to connect. Choose one.
$conn->Open("PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=$db") or exit('Cannot open with Jet.');
//$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db") or exit('Cannot open with driver.');
$sql = 'SELECT ProductName, QuantityPerUnit, UnitPrice
FROM Products
ORDER BY ProductName';
$rs = $conn->Execute($sql);
?>
<table>
<tr>
<th>Product Name</th>
<th>Quantity Per Unit</th>
<th>Unit Price</th>
</tr>
<?php while (!$rs->EOF) { ?>
<tr>
<td><?php echo $rs->Fields['ProductName']->Value ?></td>
<td><?php echo $rs->Fields['QuantityPerUnit']->Value ?></td>
<td><?php echo $rs->Fields['UnitPrice']->Value ?></td>
</tr>
<?php $rs->MoveNext() ?>
<?php } ?>
</table>
<?php
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
anybody see any obvious probelms here? I have attached a screen shot of my databse so you can see the fields
Thanks folks
J