title: Warning: sqlsrv_query() expects parameter 1 to be resource, string given
body: <p><strong>Setup</strong></p>
  
  <p>MS IIS server</p>
  
  <p>MSSQL DB Server</p>
  
  <p>PHP</p>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Warning: sqlsrv_query() expects parameter 1 to be resource, string given in C:\inetpub\wwwroot\creating_new_table.php on line 36
  Table creation failed with error:\n
  Fatal error: Call to undefined function sqlsrv_get_last_message() in C:\inetpub\wwwroot\creating_new_table.php on line 39
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>$serverName ="NAME\SQLEXPRESS";
  $usr="sa";
  $pwd="pasw";
  $db="DBNAME";
  
  $connectionInfo = array("UID" =&gt; $usr, "PWD" =&gt; $pwd, "Database" =&gt; $db);
  
  $conn = sqlsrv_connect($serverName, $connectionInfo);
  if( $conn )
  {
      echo "Connected";
  }
  else
  {
      echo "Error";
      die( print_r( sqlsrv_errors(), true));
  }
  
  $sql = "CREATE TABLE fyi_links ("
      . " id INT NOT NULL VARCHAR (6)" 
      . ", url VARCHAR(80) NOT NULL"
      . ", notes VARCHAR(1024)"
      . ", counts INT"
      . ", time DATETIME"
      . ")";
  $res = sqlsrv_query($sql,$conn);
  if (!$res) {
      print('Table creation failed with error:\n');
      print("   ".sqlsrv_get_last_message()."\n");
  }
  else {
      print("Table fyi_links created.\n");
  }  
  
  mssql_close( $conn);
  </code></pre>
  
  <p>Connection is fine but something happens with my create table script.</p>