title: PHP PDO Connection to Azure SQL - Invalid Object Name [table]
body: <p>A client has set up an SQL database on the Azure cloud. I am trying to use PDO to connect, but as soon as I try to access a table's data, I get an error message.</p>
  
  <p>My code to connect:</p>
  
  <pre><code>try {
      $db = new PDO('sqlsrv:server=tcp:serverid.database.windows.net,1433;Database=testdb','user','pass');
      $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  } catch (Exception $e) {
      echo "Error " . $e-&gt;getMessage();      
  }
  </code></pre>
  
  <p>This works fine and produces no errors. My code to insert...</p>
  
  <pre><code>try {
      $sql = "INSERT INTO tablename (introduction) VALUES (:introduction)";
      $q = $db-&gt;prepare($sql);
      $q-&gt;execute(array(':introduction'=&gt;'hi'));    
  } catch (Exception $e) {
      echo "Error " . $e-&gt;getMessage();      
  }
  </code></pre>
  
  <p>I get the following error from that</p>
  
  <pre><code>Error SQLSTATE[42S02]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'tablename'. 
  </code></pre>
  
  <p>Tablename is definitely a table which does exist. We have checked permissions and don't believe it's that. I am stuck. PDO is new to me so I don't know if there's something obvious I've missed??</p>