title: PHP and MYSQL: Query returns null on column with values
body: <p>I have a problem with a simple SQL query:</p>
  
  <pre><code>SELECT a.idElemento, b.nombre, b.descripcion
  FROM productos_elementos a
      INNER JOIN elementos_adicionales b
          ON a.idElementoAdicional=b.id_elemento_adicional
      INNER JOIN precio_elemento c
          ON a.idElemento=c.idElemento
  WHERE a.idProducto = 1 AND c.idPolitica = 1
  </code></pre>
  
  <p>When I execute this query on my database, it returns:</p>
  
  <pre><code>IdElemento Nombre  Descripcion
      1        p1       p1_desc
      2        p2       p2_desc
  </code></pre>
  
  <p>However my PHP code returns me this values:</p>
  
  <pre><code>IdElemento Nombre  Descripcion
      1       null       null
      2       null       null
  </code></pre>
  
  <p>I don't know why that it's happening. Any ideas?
  This is the code:</p>
  
  <pre><code>//$query is a string with the querty: SELECT....
  $result = $this-&gt;conn-&gt;query($query);
  $aux = $result-&gt;fetchAll(PDO::FETCH_OBJ);
  $results_to_send = json_encode($aux);
  </code></pre>
  
  <p>If I print the $variable $results_to_send at this moment, it is initialized to: </p>
  
  <pre><code>[{"idElemento":"1","nombre":null,"descripcion":null},{"idElemento":"2","nombre":null,"descripcion":null}]
  </code></pre>
  
  <p>I use the values in this piece of code:</p>
  
  <pre><code>foreach ($results_to_send as $key =&gt; $value){
  ...
  echo $value-&gt;idElemento //It prints 1 or 2
  ...
  echo $value-&gt;nombre //It is null
  ...}
  </code></pre>
  
  <p>UPDATE:
  Finally I have found the problem. I don't know how to resolve it yet, but it's a start.</p>
  
  <p>The problem is the string stored in the database. Both columns have characters with accents. For example the first row is: (1,p1_náme, p1_désc). It returns (1, null, null)</p>
  
  <p>If I change it for (1,p1_name, p1_desc), it returns (1,p1_name, p1_desc).</p>
  
  <p>UDATE 2:
  Problem solved thanks to Andrew Mackrodt comment ^^</p>