title: PDO prepare() fails on one server only
body: <p>The following code:</p>
  
  <pre><code>class Database {
      (...)
      public function query($query){
          $this-&gt;stmt = $this-&gt;dbh-&gt;prepare($query);
      }
      (...)
  }
  </code></pre>
  
  <p>Is failing on my online server with the following error:</p>
  
  <pre><code>2018/04/02 15:16:14 [error] 3472#3472: *3 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function prepare() on null in /var/www/html/example.com/public_html/includes/pdodatabaseconnect.php:38
  Stack trace:
  #0 /var/www/html/example.com/public_html/index.php(52): Database-&gt;query('SELECT * FROM s...')
  #1 {main}
    thrown in /var/www/html/example.com/public_html/includes/pdodatabaseconnect.php on line 38" while reading response header from upstream, client: XX.XXX.XXX.XXX, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "example.com"
  </code></pre>
  
  <p>Whereas the exact same code, mirrored, works fine on my local server. I can't see any <code>PDO</code> differences introduced in <code>PHP</code> versions that would create this different outcome. There's a few suggestions online for amending similar classes to fix the issue but this seems like hitting a nail with a sledgehammer - The code works on a different server with mirrored files and on another server running a different project but the exact same database class file.</p>
  
  <p>I'm unsure of what possible differences a server configuration could make to executing the code when the version differences involved are only minor and I can't spot any changes that would reflect the error I'm seeing.</p>
  
  <h1>Servers:</h1>
  
  <h2>local (MAMP)</h2>
  
  <p>PHP: 7.2.1 /
  MySQL: 5.6.38 /
  nginx: 1.13.2</p>
  
  <h2>online (Ubuntu 16.04)</h2>
  
  <p>PHP: 7.0.28 / 
  MySQL: 5.7.21 / 
  nginx: 1.10.3</p>