以下是php7上的测试 sqlsrv扩展

<"Content-type: text/html; charset=utf-8");
    $serverName = "192.168.0.1"; //数据库服务器地址
    $uid = "site_user"; //数据库用户名
    $pwd = "zkJ1246g"; //数据库密码
    $connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>"db_site");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    if( $conn == false)
    {
        echo "连接失败!";
        die( print_r( sqlsrv_errors(), true));
    }else{
        echo "连接成功!";
    }
    #$query = sqlsrv_query($conn, "select * from 数据库表");
    #while($row = sqlsrv_fetch_array($query))
    #{
    # print_r($row);
    #}
"htmlcode">
<"192.168.17";
  $dbname = "lee";
  $username = "le2r";
  $pwd = "le52";
  $dsn="dblib:host=$hostname;dbname=$dbname;charset=UTF-8";
 
  $conn = new PDO ($dsn,$username,$pwd);
  $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  echo "mssql database connnection sucessed!\n";
  } catch (PDOException $e) {
  echo "Failed to get DB handle: " . $e->getMessage() . "\n";
  exit;
  }
 
?>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!