An error occurred while reading the access table in php.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.