title: MYSQL/PHP scandinavian letters
body: <p>I have a PHP file that gets data from mysql table and then json encodes it. Everything works fine until there is a row in mysql that has scandinavian letters. Then it only returns null</p>
  
  <pre><code>  {"key":[{"Name":null}]}
  </code></pre>
  
  <p>How can i make it work? Is the problem in PHP or in MYSQL? I tried to put <code>header('content-type: text/html; charset: utf-8');</code> to the beginning of the php file, but that didn't work</p>
  
  <pre><code>&lt;?php
  header('content-type: text/html; charset: utf-8');
  include 'config.php';
  
  
  $sql = "Select * from table;
  
  
  
  try {
      $dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);  
      $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      $stmt = $dbh-&gt;query($sql);  
      $results = $stmt-&gt;fetchAll(PDO::FETCH_OBJ);
      $dbh = null;
      echo '{"key":'. json_encode($results) .'}'; 
  } catch(PDOException $e) {
      echo '{"error":{"text":'. $e-&gt;getMessage() .'}}'; 
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>When I use this code:</p>
  
  <pre><code>&lt;?php
  $con = mysql_connect("localhost","adsasd","asdasd");
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db("table", $con);
  
  $result = mysql_query("SELECT NAME from table where ID=1");
  
  while($row = mysql_fetch_array($result))
    {
    echo $row['TABLE'];
    }
  
  mysql_close($con);
  ?&gt; 
  </code></pre>
  
  <p>It shows the letter as they should be: äöåäö</p>
  
  <p>So the problem is in the <code>json_encode()</code> part?
  And why does it make the whole row appear as null instead of just making the scandinavian letters to appear as � signs or something?</p>