Hey, I'm designing a Flash website with a form for visitors to leave comments, which feeds them to a MS Access document. When the form is submitted, I get this error message:

// ODBC Error: PHP Warning: odbc_exec() []: SQL error: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query., SQL state S1000 in SQLExecDirect in C:\All_web\stnl\comments.php on line 12

The thing is, the database is being written to properly, I open it up and all the web-entered text is in there, so what is my problem? My short PHP script follows:

<?php
$name = $POST['name'];
$email = $
POST['email'];
$comments = $_POST['comments'];

// Open a connection to the database:
$conn=odbc_connect("stnlcomments", "", "");
if (!$conn) {
exit("Connection Failed: " . $conn);
}
$sql="INSERT INTO comments (name, email, comments) VALUES ('$name', '$email', '$comments')";
$rs=odbc_exec($conn,$sql);
if (!$rs){
exit('ODBC Error: ' . $rs);
}
// Clean up
odbc_close($conn);

?>

Answers to this would be much appreciated.

    I've only connected to MS Access from PHP once before - and I didn't see that error - so I can only give you my best guess.

    It appears as if the ODBC driver isn't recognizing the response from Access. For example, if the ODBC driver was written 4 years ago and only understands the response from Access, "QUERY SUCCESSFUL", but the newer version of Access is responding with some other message like, "INSERT COMPLETE" or something like that, then the driver is going to say, "Whatever you were trying to do (Insert) didn't work."

    If I were you, I'd begin to troubleshoot this by Googling for parts of that error message and see if anyone else has had this problem. Google for: php odbc driver "Operation must use an updateable query" or something like that.

    Also, I'd try to research version compatibilities of your PHP install and MS Access. You might simply need an updated driver for PHP. Or you could switch to MySQL 😉 .

      All is resolved now, after updating drivers for everything.

        Write a Reply...