title: PDO: Can't connect to mysql when host is set in variable
body: <p>i'm in trouble. I'm trying to connect remote mysql server with pdo (php 5.4.12). With this code it's connect normally:</p>
  
  <pre><code>$dbh=new PDO('mysql:host=xxx.xxx.xxx.xxx;dbname=newdb', $user, $pass);
  </code></pre>
  
  <p>But, if i try set host with variable, like this:</p>
  
  <pre><code>$host='xxx.xxx.xxx.xxx';    
  $dbh=new PDO('mysql:host='.$host.';dbname=newdb', $user, $pass);
  </code></pre>
  
  <p>It's just thinks sometime, and tell me:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'PDOException' with message ' in
    D:\wamp\www\test.php on line 21
    21 it's line of creating new PDO object.</p>
  </blockquote>
  
  <p>Ok, i'm try to catch exception (sorry, it's new for me), and now i have this:</p>
  
  <blockquote>
    <p>Error!: SQLSTATE[HY000] [2002]</p>
  </blockquote>
  
  <p>Can you help me, please?</p>
  
  <p>Double quoting not helps</p>
  
  <pre><code>$dbh = new PDO("mysql:host=$host;dbname=newdb", $user, $pass);
  </code></pre>
  
  <p>Nothing changed.</p>
  
  <p>var_dump('mysql:host='.$host.';dbname=newdb');</p>
  
  <blockquote>
    <p>string 'mysql:host=xx.xx.xxx.xxx;dbname=newdb' (length=37)</p>
  </blockquote>
  
  <p>Way with {} not helped for me.</p>
  
  <p>Ok, the situation becomes clear. I'm try to connect another server on another IP, and it's normally connected. Can it be mysql server security options?</p>