PHP and Access

This is a discussion on "PHP and Access" within the PHP Forum section. This forum, and the thread "PHP and Access are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 30th, 2005, 11:31
Junior Member
Join Date: Nov 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
PHP and Access

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
Attached Images
File Type: gif db.gif (7.9 KB, 34 views)
Reply With Quote

Reply

Tags
php, access

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to access my Phixon Databases 1 Apr 2nd, 2008 16:56
ASP Multi users Access to Microsoft Access ish Classic ASP 0 Apr 26th, 2007 20:05
Access cheataweb Databases 4 Mar 21st, 2007 18:42
ASP to ACCESS ntgcmlfu Classic ASP 16 Apr 18th, 2006 03:33
Need help please...ASP and Access DB newbie44 Classic ASP 13 Sep 19th, 2005 22:02


All times are GMT. The time now is 01:58.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43