php ODBC连接sqlserver

 $server='127.0.0.1';    
 $username='user'; //数据库用户名   
 $password='pwd';   //数据库密码
 $database='test';     //数据库
    
 $connstr = "Driver={SQL Server};Server=$server;Database=$database";    
 $link=odbc_connect($connstr,$username,$password,SQL_CUR_USE_ODBC);
 if ($link){    
   echo  "Connect successfully!<br>";   
 }else{    
   echo "Couldn't connect to SQL Server on $server";    
 }   

//---------测试数据连接-----//
 $jack=MD5('123');
 echo $jack;
 $sql="select * from admin where admin_pwd='$jack'";  
 $exec=odbc_exec($link,$sql);
 $row =odbc_fetch_array($exec);
 echo $row['admin_uid'];

你可能感兴趣的:(sql,数据库,PHP,server,server,database,sqlserver)