I'm trying to get data from a mysql table and send it via a php script as a json string so it later can be used by for example ios apps.
The code i have so far is:
<?php
$con = mysql_connect("xxx", "xxx", "xxx");
mysql_select_db("FreeSir_MarinaLaroverket") or die("Unable to select database");
$arr = array();
$rs = mysql_query("SELECT * FROM Nyheter");
while($obj = mysql_fetch_assoc($rs))
{
$arr[] = $obj;
}
echo json_encode($arr);
?>
But when i use the script i get the following:
[{"Index":"1","Title":null,"News":null,"Date":"11\/1"},{"Index":"2","Title":"Andra nyheten","News":null,"Date":"22\/2"}]
As you might see there, i have some null values that pops up there from nowhere. I've doublechecked that i have the correct values inserted and all, but it still just gives me null.
I would appreciate it if anyone of you could see what is making this code not giving me all the values i want.
Best Regards
FreeSirenety
var_dump($arr)? to see what is inside?