title: SQLSTATE[HY000][2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
body: <h3>My problem:</h3>
  
  <hr>
  
  <p>I use MAMP and Git to view and edit my PHP files with SQL database connection on my mac and then push it to the web server. I recently added a file directory. Here is the file with the SQl database connection:
  </p>
  
  <pre><code>&lt;?php
  ob_start();
  session_start();
  
  //set timezone
  date_default_timezone_set('America/New_York');
  
  //database credentials
  define('DBHOST','mysql.hostinger.co.uk');
  define('DBUSER','u536535282_evan7');
  define('DBPASS','...');
  define('DBNAME','u536535282_dbsql');
  
  //application address
  define('DIR','http://w-o-l.ml/');
  define('SITEEMAIL','it@w-o-l.ml');
  
  try {
  
      //create PDO connection
      $db = new PDO("mysql:host='.DBHOST.';port=8889;dbname='.DBNAME, DBUSER, DBPASS.'");
      $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
  } catch(PDOException $e) {
      //show error
      echo '&lt;p&gt;'.$e-&gt;getMessage().'&lt;/p&gt;';
      exit;
  }
  
  //include the user class, pass in the database connection
  include('classes/user.php');
  $user = new User($db);
  
  ?&gt;
  </code></pre>
  
  <p>But yet it returns the following error on the page:</p>
  
  <blockquote>
    <p>SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known</p>
  </blockquote>
  
  <h3>How do i fix it?</h3>
  
  <hr>
  
  <p>I cannot see my error so if someone could point it out, that would be helpful.</p>