PHP连接access

WBOY
Release: 2016-06-23 13:36:40
Original
1002 people have browsed it

PHP连接access有很多方法,odbc扩展是默认开通的,也是容易成功的,PDO方法需要开通PDO扩展;

1,PHP连接ACCESS使用ODBC扩展

<?php //需要驱动路径,数据库名,数据库密码$Driver="DRIVER=Microsoft Access Driver (*.mdb);dbq=".realpath("./database/tomonitor8.mdb");$database_name="";$database_password="20121110";$cn=odbc_connect($Driver,$database_name,$database_password,SQL_CUR_USE_ODBC ) or die(odbc_errormsg());//采用一句话连接,不过不太容易看懂使用了哪些// $cn=odbc_connect("DRIVER=Microsoft Access Driver (*.mdb);dbq="//  	             .realpath('./database/tomonitor8.mdb'),"","20121110",SQL_CUR_USE_ODBC ) or die(odbc_errormsg());$rs = odbc_exec ($cn,"select * from LOGS_HE20100618 where logs_time like '%2014-07-15 17:00:00'");while(odbc_fetch_row($rs)){//odbc_result($rs,'列名')也同样支持	echo odbc_result($rs, 1).'->'.odbc_result($rs, 2).'<br>';}odbc_free_result($rs);odbc_close($cn);
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!