Home  >  Article  >  Backend Development  >  PHP配置,链接access数据库_PHP

PHP配置,链接access数据库_PHP

WBOY
WBOYOriginal
2016-06-01 12:31:10875browse

Access

首先下载 php-5.1.1-installer.exe

才2M多,刷的就下来了,okok,然后运行,转到D盘吧,一路顺风,点击next。然后建一个目录php,新建文件info.php输入代码:



phpinfo(); ?>

在iis里数据http://localhost/php/info.php
如果出现一长串的PHP Version 5.1.1等样子的话,恭喜,配置好了。
如图:

新建php/data/db.mdb,建表szd_t,输入点数据吧,如图:

建立文件default.php;输入:

$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("data/db.mdb");

$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from szd_t",$conn,1,1);
while(! $rs->eof) {
$f = $rs->Fields(1);
echo $f->value;
$rs->MoveNext();
}
?>

浏览,还打印你刚在数据库的记录,成功成功,哈哈哈,完毕。如图:

Statement:
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