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

作者:袖梨 2022-06-24

//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");  

//oracle

 代码如下 复制代码
$conn = oci_connect("databasename","passwd","sid");
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ent_quotes), e_user_error);
}

//mysql

    

 代码如下 复制代码
$conn=mysql_connect("localhost","root","admin") or die("数据库服务器连接错误".mysql_error());
     mysql_select_db("admin",$conn) or die("数据库访问错误".mysql_error());
     mysql_query("set names gb2312");

相关文章

精彩推荐