title: php json_encode returns blank for array
body: <p>I am trying to return the result of a mysql query as json, but the json_encode function always returns a blank although the array contains elements.</p>
  
  <p>Here is the relevant code</p>
  
  <p>Retrieve the query and convert to php array:</p>
  
  <pre><code>$sql = "blablabla";
  $clients = mysql_query($sql, $con);
  
  $result = array();
  while($row = mysql_fetch_assoc($clients)) {
      //echo "rij: " . $row['name'];
      $result[] = $row;
  }
  </code></pre>
  
  <p>Then I return the result:</p>
  
  <pre><code>echo json_encode($result);
  </code></pre>
  
  <p>This returns nothing, while I do get results when echoing the following statements:</p>
  
  <pre><code>echo count($return);
  </code></pre>
  
  <p>returns 1</p>
  
  <pre><code>echo $return[0];
  </code></pre>
  
  <p>returns "Array"</p>
  
  <pre><code>echo $return[0]['name'];
  </code></pre>
  
  <p>returns "YOUREKA! demo"</p>
  
  <p>Any idea what I am doing wrong?</p>
  
  <p>Edit: I have one record that is and should be returned which contains following data:</p>
  
  <p>id: 2,
  name: YOUREKA! demo,
  address: Italiëlei 26,
  postalcode: 2000,
  city: Antwerpen,
  country: België,
  countrycode: BE,
  telephone: +32-476061346,
  email: mats@youreka.be,
  distance: 30.762980999827132,</p>