Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

PHP and MS Access

Thread Tools
 
Search this Thread
 
Old 25 April 2006, 03:48 PM
  #1  
mykp
Scooby Regular
Thread Starter
 
mykp's Avatar
 
Join Date: Jan 2006
Location: On the Cat and Fiddle
Posts: 1,483
Likes: 0
Received 0 Likes on 0 Posts
Default PHP and MS Access

Not one for asking for help but I figured somebody on here might be able to answer me this question.

Can PHP be used to pull data from a MS Access database? Using something like a Jet database connection.

Let me explain why I ask. I a few websites which currently use ASP to access a MS access database to pull information out of and need to do the same with PHP.

I dont want to go down the route of SQL as I wont be maintaining these sites and Access is easier for a client to maintain locally and then upload when required. Also these arent high hit websites. I also want to use access as some of the tables pull values out of other tables.

If this is possible can somebody point me either at a website with code I can modify or at a book which explains this.

cheers
mike
Old 25 April 2006, 04:01 PM
  #2  
bob269
Scooby Regular
 
bob269's Avatar
 
Join Date: Mar 2003
Posts: 2,654
Likes: 0
Received 1 Like on 1 Post
Default

This any use?

http://www.phpfreaks.com/tutorials/61/0.php
Old 25 April 2006, 05:38 PM
  #3  
mykp
Scooby Regular
Thread Starter
 
mykp's Avatar
 
Join Date: Jan 2006
Location: On the Cat and Fiddle
Posts: 1,483
Likes: 0
Received 0 Likes on 0 Posts
Default

Its something I could do, but i'd rather not use ODBC either. In asp I use somthing like this:

<%
Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("dbname.mdb")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
SQL_query = "SELECT id FROM pages while id = " & request.querystring("id")

Set ddb = MyConn.Execute(SQL_query)


ddb.close
Myconn.close
set Myconn = nothing
%>


I just want something really cheap and dirty to do the same in php.

Basically the site this will be running on will need to get the id of an item from the URL, ie: page.php?id=100. The database then looks up item 100 in the db and loads its contents, where its displayed.

mike
Old 25 April 2006, 07:09 PM
  #4  
mykp
Scooby Regular
Thread Starter
 
mykp's Avatar
 
Join Date: Jan 2006
Location: On the Cat and Fiddle
Posts: 1,483
Likes: 0
Received 0 Likes on 0 Posts
Default

This works on a windows server but not Unix?!

<?
$db_connection = new COM("ADODB.Connection");

$db_connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("somedb.mdb") ." ;DefaultDir=". realpath("../");
$db_connection->open($db_connstr);
$rs = $db_connection->execute("SELECT * FROM pages");
$rs_fld0 = $rs->Fields(0);
$rs_fld1 = $rs->Fields(1);
$rs_fld2 = $rs->Fields(2);
while (!$rs->EOF) {

/* do some stuff with the results to make it look nice on screen */
/* but as an example... */

print "$rs_fld0->value $rs_fld1->value $rs_fld2->value\n<br>";

$rs->MoveNext(); /* updates fields! */
}
$rs->Close();
$db_connection->Close();

?>
Old 25 April 2006, 07:40 PM
  #5  
GaryK
Scooby Regular
 
GaryK's Avatar
 
Join Date: Sep 1999
Location: Bedfordshire
Posts: 4,037
Likes: 0
Received 0 Likes on 0 Posts
Default

You wont be able to use an access mdb on *nix systems its windows only. If you're hosting on *nix then with php you really need to be looking at mysql which is open source, also get hold of phpmyadmin which is a web based tool for administering mysql databases.

Gary
Old 25 April 2006, 07:45 PM
  #6  
mykp
Scooby Regular
Thread Starter
 
mykp's Avatar
 
Join Date: Jan 2006
Location: On the Cat and Fiddle
Posts: 1,483
Likes: 0
Received 0 Likes on 0 Posts
Default

Yeah! i've asked my isp a few questions about this and am awaiting there reply. I dont want to go down the sql route as its extra work that I could do without! Plus I have to provide the client with a means of updating this. it would be much easier to say heres a database, off you go! I think i'll be using Perl and a CSV database if they persist in using there current host.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
JimBowen
ICE
5
02 July 2023 01:54 PM
TylerD529
General Technical
2
09 October 2015 01:53 AM



Quick Reply: PHP and MS Access



All times are GMT +1. The time now is 04:42 PM.