Note that there are some explanatory texts on larger screens.

plurals
  1. POjson_encode for mysql query returns some null columns of some rows, but the columns aren't null
    primarykey
    data
    text
    <p>I'm creating a little php file to get mysql rows for my android application. to retrieve each single row i use:</p> <pre><code> $q=mysql_query($sql, $this-&gt;conn) or die (mysql_error()); while($e=mysql_fetch_assoc($q)) { $output[]=$e; } print(json_encode($output)); </code></pre> <p>but sometimes it returns me an inconsistent output.</p> <p>Here's an example: The row:</p> <p>id=1 (correct) - name="name1" (correct) - price=200 (correct) - price2=null (correct) - <strong>area=null (NOT CORRECT)</strong> because area has a value of "Centro Città" .. and so on..</p> <p>How can i resolve this problem?</p> <p>EDIT: the value is</p> <p>[{"id":"84","idutente1":null,"idutente2":null,"idutente3":null,"idutente4":null,"idutente5":null,"idagente":null,"annuncio":"0","archiviato":"0","dataarchiviazione":"2012-07-05 13:31:19","tipoimmobile":"Residenziale","metodo":"Vendita","area":null,"presentazione":"1","homepage":"1","mappa":"1","nome":"Piazza Umberto I","luogo":"Crotone","descrizione":"60 mq composto da due vani oltre servizi, centralissimo buono per ufficio.","descdettagliata":" L'appartamento è diviso in due vani con cucina e bagno.&lt;/p>\r\nPosto nel pieno centro e vicinissimo al lungomare Regina Margherita.&lt;/p>\r\n Ottimo condominio. Libero e disponibile da subito. /p>","vani":"2","prezzo":"87000","prezzo1":"0","prezzo2":"0","prezzo3":"0","prezzo4":"0","prezzo5":"0","metriquadri":"58","stato":"In buono stato","riscaldamento":"Autonomo","classeenergetica":"Non dotato","piano":"Primo/secondo/terzo","indicazioni":"","mutuo":"No","banca":"","importo":"","finalita":"","tipologia":"","ammortamento":"","visite":"20","timestamp":"2012-06-25 10:48:01","nomefile":"HPIM2268.jpg"}]</p> <p>area field is not null, but is "Centro Città". The rest is correct. I tried to show only the "area" field with a mysql_fetch_assoc($query) and it returns me the correct result: "Centro Città". This problem is only with json_encode.</p> <p>The SQL Variabile is:</p> <pre><code>$sql = sprintf("SELECT i.*, f.nomefile FROM immobili i LEFT JOIN foto f on(i.id=f.idimmobile AND f.copertina=1) WHERE i.id=%s", $_GET['id']); </code></pre> <p>This is only an example, if i ask other rows, the area field returns correctly also with json_encode and other fields return null. Could it be a problem related with the strings and the text format?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload