PHP连接SQL Server

  <?php  
   
  /** 
  * @author samsun 
  * @copyright 2007 
  * php使用ODBC连接sql server数据库实例 
  */  
   
  $server='ip地址或服务器名';  
  $username='数据库用户名';  
  $password='数据库密码';  
  $database='数据库名';  
  
  $connstr = "Driver={SQL Server};Server=$server;Database=$database";  

  if ( !odbc_connect($connstr,$username,$password,SQL_CUR_USE_ODBC)){  
    echo "Couldn't connect to SQL Server on $server";  
  }else{  
    echo "Connect successfully!<br>";  
  }  
 ?>  

你可能感兴趣的:(sql,PHP,SQL Server)