title: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. PHP error
body: <pre><code>Notice: Array to string conversion in C:\xampp\xampp\htdocs\classes\DB.php on line 21
  
  Warning: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\xampp\htdocs\classes\DB.php on line 21
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known.
  </code></pre>
  
  <p>It gives me this error when its on XAMPP, but when i put it on a live server it works fine, I know the DB credentials are correct, I am using the current version of XAMPP (as of yesterday)  for windows and using Apache 2 on the live server, both with MySql.</p>
  
  <p>Line 18-25:</p>
  
  <pre><code>// Takes values from 'config.php' and uses them to connect
  private function __construct() {
      try {
          $this-&gt;_pdo = new PDO('mysql:host=' . Config::get('msql/host') . ';dbname=' . Config::get('mysql/db'), Config::get('mysql/username'), Config::get('mysql/password'));
      } catch(PDOException $e) {
          die($e-&gt;getMessage());
      }
  }
  </code></pre>
  
  <p>And this is where the array is set:</p>
  
  <pre><code>// Sets the config valuses
  $GLOBALS['config'] = array(
      'mysql' =&gt; array(
          'host' =&gt; '127.0.0.1',
          'username' =&gt; 'root',
          'password' =&gt; 'password',
          'db' =&gt; 'site'
      ), 
      'remember' =&gt; array(
          'cookie_name' =&gt; 'hash',
          'cookie_expiry' =&gt; 604800
      ), 
      'session' =&gt; array(
          'session_name' =&gt; 'user'
      ) 
  );
  </code></pre>
  
  <p>And the config class:</p>
  
  <pre><code>class Config {
      public static function get($path = null) {
          if($path) {
              $config = $GLOBALS['config'];
              $path = explode('/', $path);
  
              foreach($path as $bit) {
                  if(isset($config[$bit])) {
                      $config = $config[$bit];
                  }
              }
  
              return $config;
          }
  
          return false;
      }   
  }
  </code></pre>