I'm trying to fetch data from a MariaDB database of festivals and respective locations. When running:
while($row = $sth->fetch_assoc()){}
and iterating over $row while outputting the values, I get data as it is in the database. However, when storing each row like so:
while($row = $sth->fetch_assoc()){
$results[] = $row;
}
And echoing the results as JSON (echo json_encode($results);) I get this:
{"id":"0","name":null,"village":"0","startDate":"2019-01-16",
"endDate":"2019-01-23","message":null}
This is for an existing Linux server, which I do not manage (I'm using CPanel). PHP version is 5.4 and MariaDB 10.1.37.
So far, a lot of code samples on Stack Overflow and other websites are using $results[] = $row; for storing the results. I'm returning to PHP after 3 years of Swift only programming... So I suspect this could be a simple issue to solve...
Thanks!