When php reads an access table, the following error occurs: Warning: odbc_do () [function. odbc-do]: SQL error: [Microsoft] [ODBC Microsoft Access Driver]. an updatable query is required ., SQL state S1000 in SQLExecDirect in F: \ mygbk \ admin \ action \ MupAction. class. php on line 24
How to correct error display
Reply to discussion (solution)
The directory where the library file is located must have read and write permissions for general users. Please check
After checking, the permission is OK. You can also connect to access, that is, the insert record fails.
It depends on your code.
$ Mydb = realpath ('./first. mdb ');
$ Connstr = "Driver = {Microsoft Access Driver (*. mdb)}; Dbq = $ mydb ";
$ Connid = odbc_connect ($ connstr, '','', SQL _CUR_USE_ODBC) or die ('database connection failed! Contact the administrator ');
/* $ SQL = "create table content (id counter constraint primarykey primary key, [TITLE?] Varchar (50) null, [province/city] varchar (30) null, [content] varchar (255), [acquired] bit, [sent] bit )";
Odbc_exec ($ connid, $ SQL );*/
// $ SQL = "select * from content ";
$ Data = $ this-> m-> select ('content ');
$ Mtitle = $ data [0] ['title'];
$ Province = $ data [0] ['Province and City '];
$ Chats = $ data [0] ['content'];
$ Sql1 = "insert into content (title, province/city, content, collected, sent) values ('$ mtitle',' $ province ',' $ chats )";
$ Query = odbc_do ($ connid, $ sql1 );
Echo $ query;
If ($ query ){
Showmessage ('success ');
} Else {
Showmessage ('failed ');
}
Odbc_close ($ connid );
I happen to have the mdb created by your last question.
As long as you have permissions, there is no problem
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = ". realpath ("db1.mdb"); $ connid = odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC); odbc_do ($ connid, "insert into content (title) values ('Haha ') "); $ qid = odbc_do ($ connid," select * from content "); odbc_result_all ($ qid );
The connection created by SQL _CUR_USE_ODBC in php4 is read-only, so you will not still use php4.
I wrote a different answer for php5.2 and later versions, but why didn't I insert the record into the access database?
Yes! The code is the same, but I have permissions, and you have no permissions.
If you look for an asp-related question, you will be told that you do not have the permission.