title: pdo_sqlsvr SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]TCP Provider
body: <p>I am trying to connect remotely to the mssql server by using <code>pdo sql_srv</code> but I still get error by fallwoing.<strong>PDOException</strong>:</p>
  
  <blockquote>
    <p>SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]TCP
    Provider: An attempt was made to access a socket in a way forbidden by
    its access permissions.</p>
  </blockquote>
  
  <p>I also enabled port from firewall and Server Configuration TCP enabled.</p>
  
  <pre><code>  class Database {
  
              public $error;
              public $ok;
              public $dead;
              var $query_id; 
              var $LastPDOResult;
              var $La
  
  stPDOResultCursor;
          var $SQLDebug;
          var $sql;
          // Constructor --&gt; Connect
          function __construct($SQLHOST, $SQLPORT, $SQLDB, $SQLUSER, $SQLPWD) {
              try {
  
                  if(PDODRIVER == 3) {
                      $this-&gt;db = new PDO("odbc:Driver={SQL Server};Server=".$SQLHOST.";Database=".$SQLDB."; Uid=".$SQLUSER.";Pwd=".$SQLPWD.";");
                  } else {
                      if(PDODRIVER == 2) {
                          $pdo_connect = "sqlsrv:Server=".$SQLHOST.",".$SQLPORT.";Database=".$SQLDB."";
                      } else {
                          $pdo_connect = 'dblib:host='.$SQLHOST.':'.$SQLPORT.';dbname='.$SQLDB;
                      }
                      $this-&gt;db = new PDO($pdo_connect, $SQLUSER, $SQLPWD);
                  }
  
  
              } catch (PDOException $e) {
                  $this-&gt;dead = true;
                  $this-&gt;error = "PDOException: ".$e-&gt;getMessage();
  
                  if(config('ERROR_REPORTING',true)) {
                      die($this-&gt;error);
                  } else {
                      //die('website offline');
                      die($this-&gt;error);
                  }
              }
  
          }
      }
  
  $dB = new Database(DBHOST, DBPORT, DBNAME, DBUSER, DBPASS);
  </code></pre>