Home > php教程 > php手册 > php连接mysql,oracle,mssql数据库连接代码

php连接mysql,oracle,mssql数据库连接代码

WBOY
Release: 2016-05-24 18:30:49
Original
1395 people have browsed it

php连接mssql代码如下:

$server='hbds3';    
$username='username';    
$password='pwd';    
$database='database';    
$conn=mssql_connect($server,$username,$password)    
or die("couldn't connect to sql server on $server");    
$db=mssql_select_db($database) or die("couldn't open database $database");
Copy after login

php连接oracle代码如下:

$conn = oci_connect("databasename","passwd","sid"); 
if (!$conn) { 
$e = oci_error(); 
trigger_error(htmlentities($e['message'], ent_quotes), e_user_error); 
}
Copy after login

php连接mysql,代码如下:

$conn=mysql_connect("localhost","root","admin") or die("数据库服务器连接错误".mysql_error()); 
mysql_select_db("admin",$conn) or die("数据库访问错误".mysql_error());//开源代码phprm.com 
mysql_query("set names gb2312");
Copy after login


本文地址:

转载随意,但请附上文章地址:-)

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template