PHP code for reading ACCESS data to MYSQL. The following example is relatively simple. you can use the com interface to read the access database tutorial, read the data, and then connect to the mysql tutorial database, insert the corresponding field into the mysql table and the instance below the field is relatively simple, that is, first use the com interface to read the access database tutorial, read the data and then connect to the mysql tutorial database, insert the corresponding field to the table and field corresponding to mysql.
Header ('ontent-Type: text/html; charset = GB2312 '); // avoid output garbled characters
$ Dbhost = "localhost ";
$ Dbuser = "root ";
$ Dbpassword = "123456 ";
$ Dbname = "139 miaosha ";
Mysql_connect ($ dbhost, $ dbuser, $ dbpassword) or die ("error! ");
Mysql_query ("set names 'gbk '");
Mysql_select_db ('139miaosha ');
$ Conn = new com ("ADODB. Connection ");
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ = F:/wamp/www/miaosha/ruichao858.mdb ";
$ Conn-> Open ($ connstr );
$ Rs = new COM ("ADODB. RecordSet ");
$ Rs-> Open ("select * from News where bigclassname = 'decoration class'", $ conn, 1, 3 );
While (! $ Rs-> eof ){
Switch ($ rs-> Fields [4]) {
Case "decoration consultant ":
$ Sclass = 1;
Break;
Case "kitchen space ":
$ Sclass = 2;
Break;
Case "furniture Story ":
$ Sclass = 3;
Break;
Case "electrical engineering ":
$ Sclass = 4;
Break;
Case "decoration scenery ":
$ Sclass = 5;
Break;
Case "wide angle material ":
$ Sclass = 6;
Break;
Default:
$ Sclass = 1;
}
If ($ rs-> Fields [6]) {
$ Spic = "";
} Else {
$ Spic = $ rs-> Fields [6];
}
If ($ rs-> Fields [7]) {
$ User = "";
} Else {
$ User = $ rs-> Fields [7];
}
If ($ rs-> Fields [9]) {
$ Hits = 1;
} Else {
$ Hits = $ rs-> Fields [9];
}
$ SQL = "insert into rc_news (n_title, n_content, n_bclass, n_sclass, n_pic, n_spic, n_user, n_hits, n_audit) values ('". $ rs-> Fields [1]. "','". $ rs-> Fields [2]. "', 1 ,". $ sclass. ",'','". $ spic. "','". $ user. "',". $ hits. ", 1 )";
$ Result = mysql _ query ($ SQL );
// Echo $ rs-> Fields [1];
// Echo"
";
$ Rs-> Movenext (); // move the record set pointer down
}
$ Rs-> close ();
?>
...