本文章提供了四种数据库连接程序,都针对于php的,像php mysql,与mssql是比较常用的,至于php access数据连接也有不秒人在用,还有就是利用php pdo来连接数据库代码我是在用火车头采集数据时来用的。
<script>ec(2);</script>
//php与mysql数据库连接代码
代码如下 | 复制代码 |
mysql_connect('localhost','root','root') or die( 'mysql server stop or use password error!' ); mysql_select_db('cshouse') or die( 'datebase error' ); mysql_query("set Names 'GB2312'"); |
//php 连接access数据库代码
代码如下 | 复制代码 |
$conn = @new COM("ADODB.Connection") or die ("ADO Connection faild."); $connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . $path; $conn->Open($connstr); |
//php 利用pdo连接mdb数据库,这个比较适合于火车头采集数据的用户
代码如下 | 复制代码 |
$path ="F: ontSpiderResult.mdb"; $conn = new PDO("sqlite:$path"); if( $conn ) { echo ('connection pdo success'); } else { echo ('cnnection pdo fail ,plase check database server!'); } |
// php与mssql 数据库连接代码
代码如下 | 复制代码 |
$link = mssql_connect("127.0.0.1", "sa", "sa") or die("Can't connect sql server"); mssql_select_db("frrc", $link) or die("Select database failure"); /* 好了本站原创文章转载注明来源http://www.111cn.net/phper/php.html */ |
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks agoByDDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks agoByDDD
Where to find the Crane Control Keycard in Atomfall
3 weeks agoByDDD
Saving in R.E.P.O. Explained (And Save Files)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.