PHP calls Access database through ADO _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Tags mdb database pconnect
PHP calls the Access database through ADO. After reading the article "how to call the Asscess database and COM program through ADO in PHP", I immediately did the test and the result failed. Sad. What should I do? I had to go to the PHP official website and read the article "how to call the Asscess database and COM program in PHP through ADO". then I did the test immediately and the result failed. Sad.
What should I do? I had to go to the official PHP website for help, and Huang Tianyan had no worries, and finally I found the answer --
The specific solution is as follows:
(1) log on to the secondary node (great, all types of databases can handle it ).
(2) unpackage, there are many files in it, but only ohtml is useful. inc. php and adodb. inc. php, copy them to the corresponding directory (or c: php4peer under the default directory where php4 is installed, or under the Directory of the currently running program, depending on the include () function );
(3) Then, in the c: myphp Directory of the local chicken (one incorrect word, it is a machine) (iis is set to access through http: // localhost/jhk ), created a file named test. create an experts table in the access database of mdb ....... In order to ACCESS through DSN, I named the ACCESS library test in DSN.
(4) run. Looking at the instruction book, I made such a program:
Dbtest. php:
Include (ohtml. inc. php); // load code common to ADODB
Include (adodb. inc. php); // load code common to ADODB
$ Conn = & ADONewConnection (access); // create a connection
$ Conn-> PConnect (est); // connect to MySQL, agora db
$ SQL = select name, group1 from experts;
$ Rs = $ conn-> Execute ($ SQL );
Rs2html ($ rs, order = 2 cellpadding = 3, array (Customer Name, Customer ID ));

$ Rs-> Close (); // optional
$ Conn-> Close (); // optional
?>
Then, enter http: // localhost/jhk/dbtest. php in IE.
Alas! The result is displayed. Satisfying !!
(5) next, I thought: it's annoying to set up a DSN! How should I solve the problem of bypassing DSN? Because in asp, I used to use conn. open ("provider = Microsoft. jet. OLEDB.4.0; Data Source = "& Server. mappath (".. /nydatabase. mdb ") to process the mdb Database. that's fast!
?...... I thought and thought, and read again .......
Search ,......, Hey, I finally found the answer in testdatabases. inc. php! Then I adapted the program:
Include (ohtml. inc. php); // load code common to ADODB
Include (adodb. inc. php); // load code common to ADODB
$ Db = & ADONewConnection ("ado_access ");
Print "Connecting $ db-> databaseType ...";
$ Access = est. mdb;
$ MyDSN = PROVIDER = Microsoft. Jet. OLEDB.4.0;. data source =. $ access.;. user id =; PASSWORD = ;;
If (@ $ db-> PConnect ($ myDSN ,"","","")){
Print "ADO version =". $ db-> _ connectionID-> version ."
";
$ SQL = select name, group1 from experts;
$ Rs = $ db-> Execute ($ SQL );
Rs2html ($ rs, order = 2 cellpadding = 3, array (Customer Name, Customer ID ));
} Else print "ERROR: Access test requires a Access database $ access ".
. $ Db-> ErrorMsg ();
?>
Run.
Everything is done!
This article related files site: http://www.phpe.net /? N = ShowClass & a = 106

Bytes. Sad. What should I do? I had to go to PHP official...

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.