[Solved] PHP and MS Access

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

[Solved] PHP and MS Access

Post by wpsd2006 »

Hi

I am fond of Web Apps but bump !!

I've got a fingerprint machine which is linux that connect to a database by a simple win application. Now the application can only use ms access for their database -- I hate it so much, mssql will be much better -- since their win application not quiet correct on managing the attendance data. I decided to create one of my own but using web apps and of course PHP.

I had installed all the necessary tool and program to connect to Ms Access in LINUX using ODBC driver thru DSN Connection.

It success, no problem in connecting
no problem in SELECT query, it return result.
problem with UPDATE, INSERT, DELETE query. The query doesn't effect the Database , no error return even if it's a simple query like "UPDATE test SET name = 'wpsd' WHERE id = 1"

I read that MS Access have problem with permission, but I'm able to change the database from C# win Apps but not PHP.

And also read that you won't be able to update/insert/delete table that have relationship. So I try create a simple database with one table only, the table call test and have attribute id and name . Then I try use the simple query above, but no luck.

Any one have experience using LAMP and MS Access ? All the tutorial seems only show how using SELECT query
Last edited by wpsd2006 on Mon Feb 22, 2010 5:42 am, edited 1 time in total.
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: PHP and MS Access

Post by JakeJ »

You might want to look in to this: http://www.ucl.ac.uk/is/mysql/access/
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: PHP and MS Access

Post by wpsd2006 »

I check but not exactly what I needed.
I dont want to change the access to mysql cause the win application that can download the attendance data from machine can only use access ( this is my next problem but can discuss later )

main problem is php odbc cannot manipulate access database, it can only do a "select" query

Anyone succeed in manipulate access database thru php in Linux ?
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: PHP and MS Access

Post by JakeJ »

Here's another thread that might be helpful. Pay close attention to escaping spaces and reserved words.

http://forums.codewalkers.com/database- ... 32265.html
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: PHP and MS Access

Post by wpsd2006 »

Thanks
I already check that example before, but my sql much more simple :

UPDATE test SET name = 'wpsd' WHERE id = 1

Does this query wrong in ms access ?
I try it in ms access it's working but not php.
I really have the table in ms access for testing.
It call test with only two field ( id: number, name: text )
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: PHP and MS Access

Post by JakeJ »

Are you using DSN?
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: PHP and MS Access

Post by wpsd2006 »

Yep I using DSN thru odbc.ini and using libmdbodbc.so to connect

The SELECT query works well can return result but not the other IUD (Input Update Delete) query
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: PHP and MS Access

Post by JakeJ »

Do you have access to another system to try it on. Perhaps that system has some sort of JET corruption or something.
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: PHP and MS Access

Post by wpsd2006 »

yep but not linux

I'll try it again, i hope it can works in ubuntu cause my other application using LAMP
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: PHP and MS Access

Post by JakeJ »

I meant another box with Access on it. Troubleshoot from every angle. Try to use another program to connect also. Do you have access to ASP? You have to find the source of the error, don't assume it's your php code or the php odbc driver (though it might be).
Brian Swan
Forum Newbie
Posts: 17
Joined: Thu Jan 14, 2010 11:56 am

Re: PHP and MS Access

Post by Brian Swan »

Does your test table have a PK (or unique index) defined? If not that may be the problem: Access uses a keyset cursor for updating data, which means that it fetches the first few rows and then the keys for the rest. If there’s no PK or unique index defined, it fetches a snapshot (all the rows), which is read-only.

This article might be helpful: http://msdn.microsoft.com/en-us/library ... L.90).aspx. It addresses SQL Server connectivity, but it contains information about how Access works on the client side that should be helpful.

Hope that helps.
-Brian
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: PHP and MS Access

Post by wpsd2006 »

Hmm Okay let's back to the simple prob

How do I update a table using php_odbc ?

I just call odbc_exec("UPDATE .... ") should be enough right ?
wpsd2006
Forum Commoner
Posts: 66
Joined: Wed Jan 07, 2009 12:43 am

Re: PHP and MS Access

Post by wpsd2006 »

After checking all the mdb tools and library in linux found out that it only support select query

Guess the solution is seperate the server :D
Post Reply