I have a MySQL database owns a table "news" with "ID" (Int(15)), "titel" (varchar(255)) and so on.
The following code let me get a json of the column "id". But if i want to get the column "titel" i get nothing out of this PHP.
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "SELECT `titel` FROM `news` ORDER BY `datum` DESC";
$result = mysql_query($sql);
$json = array();
if(mysql_num_rows($result)){
while($row=mysql_fetch_assoc($result)){
$json['news'][]=$row;
}
}
mysql_close($con);
echo json_encode($json);
Here the table structure out of phpMyAdmin as table (xx = empty)
Name Type Collation Attributes Null Default
id int(15) xx UNSINGED No None
titel varchar(255) lati1_swedi.. xx No xx