Common PHP Access database errors and solutions. There are two common methods for connecting php + access to the database. [www.veryhuo.com] for example, php + access is commonly used to connect to the database by establishing an odbc driver and using the php odbc_connect () function to connect to the CopytoClipboard.
1. establish an odbc driver and connect it with the odbc_connect () function of php.
Copy to ClipboardReference: [www.bkjia.com] for example: $ connstr = DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ = ". $ db;
$ Connid = odbc_connect ($ connstr, "username", "password", SQL _CUR_USE_ODBC );
2. use oledb to connect and then call the open method to open
For example:
Copy to ClipboardReference: [www.bkjia.com] $ conn = new com ("ADODB. connection ");
$ Connstr = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =". $ db;
$ Conn-> Open ($ connstr );
However, an error occurred while connecting the two methods. when I went to the Internet to find information, I said that I did not grant the Everyone permission, and some said that the access97 and access2000 drivers were different (that is, the database was built on 2000, the driver used for reading is 97 .).
The original path of the database was tested repeatedly. I used to write the database address as a relative path when developing asp, and then use the server. mappath () function to obtain its absolute path.
This habit is also continued during php Development. We use realpath and the relative path of the database to obtain the address of the database. for example: $ db = realpath ("../db. mdb ");
However, asp's include function and php's include function seem to be different in the processing of include files, resulting in php's inclusion of conn in different directories. the PHP file is connected to the database and "common errors cannot open the registry keyword ",
Or Uncaught exception 'com _ exception' with message'Source:Provider
Description:Verification failed. 'Error.
Now I will sort out the error information and solutions and post it to you. I hope other friends will not be as depressed as I do in this situation.
Php access database FAQs
Error 1:
Copy to ClipboardReference: [www.bkjia.com] Warning: odbc_connect () [function. odbc-connect]: SQL error: [Microsoft] [ODBC Microsoft Access Driver] common errors do not enable the registry keyword 'temporary (volatile) jet DSN for process 0xdd0 Thread 0xcb8 DBC 0x14bd024 Jet '., SQL state S1000 in SQLConnect in E: \ wwwroot \ phpweb \ conn. php on line 8
This error indicates that you are using the odbc access DRIVER, which is the first method to connect to the database. $ connstr = Driver = {Microsoft Access DRIVER (*. mdb)}; DBQ = ". $ db;
And the file you are currently accessing and your conn. the php database connection file is not in the same directory, including conn. the relative path used in php, such as include (".. /conn. php "), because php processes different files in the include function from asp,
Causes a database path error,
Solution:
1. check whether the path of your database is obtained by adding a relative path to the realpath () function,
For example: $ db = realpath ("../db. mdb ");
If yes, please use another method to obtain the database address. for example, use $ _ SERVER ['document _ root'] to obtain the ROOT object of your website, and add the database address,
Example: $ db = $ _ SERVER ['document _ root']. "\ db. mdb ";
2. check the permission and grant it the Everyone permission.
3. in another connection mode, the Microsoft odbc driver has some unstable bugs, which may lead to such errors. it is said that Microsoft has abandoned support for the odbc data source connection mode, we recommend that you use oledb to change the connection string as follows:
"Provider = Microsoft. Jet. OLEDB.4.0; Data Source =". $ db;
Error 2:
Copy to ClipboardReference: [www.bkjia.com] Fatal error: Uncaught exception 'com _ exception' with message'
Source:Provider
Description:Verification failed. 'In E: \ wwwroot \ phpweb \ conn. php: 7 Stack trace: #0 E: \ wwwroot \ phpweb \ conn. php (7): com-> Open ('provider = Micros... ') #1 ...............
This error indicates that you are using the oledb method to connect to the database, and it is also caused by the database path.
The solution is the same as above. use $ _ SERVER ['document _ root']. "\ db. mdb"; to obtain the database address.
Error 3:
Copy to ClipboardReference: [www.bkjia.com] Warning: odbc_connect () [function. odbc-connect]: SQL error: [Microsoft] [ODBC driver manager] no data source name is found and no default driver is specified. SQL state IM002 in SQLConnect in E: \ wwwroot \ phpweb \ conn. php on line 8
The most common cause of the error is that your connection string is wrong. The Complete connection string should be:
Copy to ClipboardReference: [www.bkjia.com] $ db =$ _ SERVER ['document _ root']. "\ db. mdb ";
$ Connstr = "Driver = {Microsoft Access Driver (*. mdb)}; Dbq = $ db; Uid = Admin; Pwd = pass ";
$ Connid = odbc_connect ($ connstr, "admin", "pass", SQL _CUR_USE_ODBC) or die ("failed to open the database! Contact the administrator ");
If your database does not have a password, Uid or Pwd can be omitted.
Copy to ClipboardReference: [www.bkjia.com] $ connstr = "Driver = {Microsoft Access Driver (*. mdb)}; Dbq = $ db ";
$ Connid = odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC) or die ("failed to open the database! Contact the administrator ");
Error 4:
Copy to ClipboardReference: [www.bkjia.com] Fatal error: Uncaught exception 'com _ exception' with message'
Source:ADODB. Connection
Description:No provider found. The program may not be correctly installed. 'In ......................
Oledb connection mode. The cause of the error is the same as above. The Complete connection string should be:
Copy to ClipboardReference: [www.bkjia.com] $ db =$ _ SERVER ['document _ root']. "\ db. mdb ";
$ Conn = new com ("ADODB. connection ");
$ Connstr = "Provider = Microsoaft. Jet. OLEDB.4.0; Data Source =". $ db;
$ Conn-> Open ($ connstr );
Protocol 1. create an odbc driver and use the php odbc_connect () function to connect to the content referenced by Copy to Clipboard: [www.veryhuo.com] such :...