title: SQLSTATE[08006] [7] could not translate host name "dbname=" to address
body: <p>I'm using the Symfony/Silex SecurityServiceProvider to login users on the site.</p>
  
  <pre><code>http://silex.sensiolabs.org/doc/providers/security.html
  </code></pre>
  
  <p>I follow the guide step by step, but when I submit the login form, I got a PostgreSQL error</p>
  
  <pre><code>SQLSTATE[08006] [7] could not translate host name "dbname=" to address
  </code></pre>
  
  <p>Whatever I set for dbname, I still got the error. Even with the right IP of the distant server. However my setup is good, because I use the same class to connect and request the server, and it always work.</p>
  
  <p>The error appears only on submitting the login form !</p>
  
  <p>My login class</p>
  
  <pre><code>&lt;?php
  
  namespace Model;
  
  use Silex\Application;
  
  abstract class Entity {
  
      private $app;
      private $host;
      private $base;
      private $port;
      private $user;
      private $pass;
      private $charset;
  
      public function __construct(Application $app)
      {
          $this-&gt;app = $app;
  
          $this-&gt;host    = $app['config']['database']['host'];
          $this-&gt;base    = $app['config']['database']['base'];
          $this-&gt;port    = $app['config']['database']['port'];
          $this-&gt;user    = $app['config']['database']['user'];
          $this-&gt;pass    = $app['config']['database']['pass'];
          $this-&gt;charset = $app['config']['database']['charset'];
      }
  
      protected function connectBDD()
      {
          $connect = new \PDO("pgsql:host=$this-&gt;host;dbname=$this-&gt;base", $this-&gt;user, $this-&gt;pass);
          $connect-&gt;setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
          $connect-&gt;query("SET NAMES '$this-&gt;charset'");
  
          return $connect;
      }
  }
  }
  </code></pre>
  
  <p>Thanks for help</p>