i am trying to get a string from a database online. My database is very simple, it has two fields: Id (int) Testo(Text)
I created a file php to get all of the text field and print them. Thats the file:
<?php
$host="*******";
$username="********";
$password="********";
$db_name="********";
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "select Testo from Frase";
$result = mysql_query($sql);
$json = array();
if(mysql_num_rows($result)){
while($row=mysql_fetch_assoc($result)){
$json['Frase'][]=$row;
}
}
mysql_close($con);
echo json_encode($json);
?>
My problem is that some filed are null, I don't know why cause if a run the query on my alter vista php admin panel it works. All of the field aren't empty. I think it could be a decode or encode characters problem. But i really don't have any knowledge about that.
I don't want to skip null values because they are not null and i need them. This is an example of sentence that comes out fine in the admin panel,but null in the browser
C'รจ una nuova notifica! (Scegli la migliore 'migliore' offerta per te!)
NULL
? Show us some output. From the code you posted I guess you don't get any output. Is that correct? Or you get a JSON-encoded text but some values are missing from it? – axiac Dec 11 '14 at 10:04