JSON-String is empty but why? The same code works fine if I change the table. There are 20 entries and the Code works today afternoon but for some reason I can't get the entries anymore :(
<?php
// open connection to mysql db
include("connect.php");
// fetch table rows from mysql db
$sql = "SELECT * FROM Videoquestions";
$result = mysqli_query($conn, $sql);
// create an array
$var = array();
while($obj = mysqli_fetch_object($result)) {
$var[] = $obj;
}
// convert array to JSON
echo '{"Videofrage":'.json_encode($var, JSON_UNESCAPED_SLASHES).'}';
// Close the database connection
$conn->close();
?>
Need to encode to utf8 ... anybody knows how to? German Umlaute like äöü are blocked and with this line of code it will be solved:
mysqli_set_charset($conn, 'utf8');