[SOLVED] ODBC MS Access probs. Can't INSERT INTO xxx VALUES

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

[SOLVED] ODBC MS Access probs. Can't INSERT INTO xxx VALUES

Post by Chris Corbyn »

Hi,

I'm just trying to write a web page in php to process data in an existing Microsoft Access Database I've got.

I've set up ODBC and I can connect and SELECT rows etc but I get probs when I try to edit the DB in any way.

When I try "INSERT INTO websites (Owner) VALUES ('JoeBloggs')" like this...

Code: Select all

<?php

$user = "xxxxx";
$pass = "xxxxxx";
$database = "clientsDB";

$connect_db = odbc_connect($database,$user,$pass) or die ('Wrong Command!!!');

$query = "INSERT INTO websites (Owner) VALUES ('owner')";

$result = odbc_do($connect_db,$query) or die ('dude something went wrong '.odbc_errormsg());

?>
I get this error
Warning: odbc_do(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query., SQL state S1000 in SQLExecDirect in d:\inetpub\wwwroot\add.php on line 13
dude[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
I've read up on this error and it just cobered the obvious read/write access issues. The dir is editable... i even tried moving it to wwwroot like it says on the Microsoft website with Read/write access but still got same prob.

Please help....

Thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Seems that if I enable file sharing on the LAN for that folder with full read/write access it works fine....

Anyone know how you set those permissions without sharing on the network because I'm actually on a LAN and dont want full read write access to all my client info. Apparently there's a security section somewhere in XP and it needs configuring for guest access to that folder???
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Found it... Just in case anyone is as dumb as me and has this problem.

Go to the folder your mdb file is in. Click tools -> folder options -> view.

Uncheck the "Use simple sharing option" box.

Click OK.

Go to folder properties and select the security tab (wasn't there before). Add a user IUSR_[COMPUTER NAME] to enable the internet guest accont and give it full access. Voila you're done.
Post Reply