PHP uses ADODB to operate ACCESS databases. Chinese garbled characters

Source: Internet
Author: User
The following code is used to operate the ACCESS database: require_onceadodbadodb.inc.php; $ connNewADOConnection (access); $ connstrDriver {MicrosoftAccessDriver (*. mdb)}; DBQ. realpath (databasetestDB. mdb ).; uid; Pwd; $ conn-Conn

The following code is used to perform operations on the ACCESS Database: require_once 'ADODB/adodb. inc. php '; $ conn = NewADOConnection (access); $ connstr = Driver = {Microsoft Access Driver (*. mdb)}; DBQ =. realpath (database/testDB. mdb ).; uid =; Pwd =; $ conn-Conn

The following code is used to perform operations on the ACCESS database:

Require_once 'ADODB/adodb. inc. php ';

$ Conn = NewADOConnection ("access ");

$ Connstr = "Driver = {Microsoft Access Driver (*. mdb)}; DBQ = ". realpath ("database/testDB. mdb "). "; Uid =; Pwd = ;";

$ Conn-> Connect ($ connstr );

$ SQL = "select * from productClass ";

$ Rs = $ conn-> execute ($ SQL );

Print_r ($ rs-> GetRows ());

However, Chinese characters read from the database are garbled. The solution is to change the code to the following format:

Require_once 'ADODB/adodb. inc. php ';

$ Conn = new COM ("ADODB. Connection", NULL, 65001) or die ("ADO connect failed! ");

$ Connstr = "Driver = {Microsoft Access Driver (*. mdb)}; DBQ = ". realpath ("database/testDB. mdb "). "; Uid =; Pwd = ;";

$ Conn-> open ($ connstr );

$ SQL = "select * from productClass ";

$ RsArr = $ conn-> execute ($ SQL );

If ($ rsArr ){

While (! $ RsArr-> eof ){

Echo $ rsArr-> fields ["id"]. "". $ rsArr-> fields ["className"]."
";

$ RsArr-> MoveNext ();

}

} Else {

Print $ conn-> ErrorMsg ();

}

$ RsArr = null;

$ Conn-> close ();

$ Conn = null;

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.