title: PHP PDO changes remote host to local hostname
body: <p>I'm trying to connect to a remote mysql server using PDO. However, regardless of the hostname or ip address i supply in the dsn, when the script is run it always reverts the address to the hostname of the local server where the webserver is running.</p>
  
  <p>Google suggests this could be something to do with SELinux and apaches ability to connect to remote databases, however i have SELinux disabled.</p>
  
  <p>Distro: Ubuntu 11.04 x64</p>
  
  <p>Apache version: 2.2.17</p>
  
  <p>PHP Version: PHP 5.3.5-1ubuntu7.11 with Suhosin-Patch (cli)</p>
  
  <p>Edit:</p>
  
  <p>Added code as requested. Though i dont believe this is an issue with my coding as it works fine on the local server, but doesnt allow remote connection.</p>
  
  <pre><code>public function db_connect($driver, $dbhost, $dbname, $user, $pass) {
      $dsn = $driver . ':host=' . $dbhost . ';dbname=' . $dbname;
      try {
          $this-&gt;DB = new PDO($dsn, $user, $pass);
      }
      catch (PDOException $err) {
          print 'Database Connection Failed: ' . $err-&gt;getMessage();
          die();
      }
  }
  
  $remote_db = new DB('mysql', 'remote_server.domain.tld', 'database_name', 'user_name', 'password');
  </code></pre>
  
  <p>This is the error message i am receiving. </p>
  
  <blockquote>
    <p>Database Connection Failed: SQLSTATE[28000] [1045] Access denied for user 'user_name'@'local_server.domain.tld' (using password: YES)</p>
  </blockquote>