Php access data solution

Source: Internet
Author: User
For php access data operations, I have an access data file db. mdb. now I want to convert his data into mysql data. How can I operate this db. mdb using php. I only need to read it, and then insert the read information into the mysql database I created. That person has done it. thank you !, $ Mdb = & quot; database name php operation access data
I have an access data file db. mdb. now I want to convert his data into mysql data. How can I operate this db. mdb using php. I only need to read it, and then insert the read information into the mysql database I created. Thank you for doing this!

------ Solution --------------------
$ Mdb = "database name. mdb ";
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ =". realpath ($ mdb );
$ Conn = odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC );

$ Rs = odbc_exec ($ connid, "select * from table name ");
While ($ row = odbc_fetch_array ($ rs )){
// It can be directly used here, and it is not necessary to go to mysql
$ Row = array_map ('addslashes', $ row); // Escape Special characters
Mysql_query ("insert into table name values ('". join ("', '", $ row). "')"; // insert a mysql table
}

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.