I have following problem:
I have this code simplifyied:
$contents = $pdo->query($sql);
$results = $contents->fetchAll(PDO::FETCH_ASSOC);
foreach($results as $row) {
$string = htmlspecialchars($row['content']);
array_push($all_matches, array("data" => $string, "id" => $row["page_id"]));
}
echo json_encode($all_matches);
And in my database I have following content for example:
<h1>MRG Beispiel Seite</h1>
<h2>Ein Beispiel für Einbindung einzelner Felder / Strings aus dem Impressum-Modul:</h2>
And my result is following:
[{data: "", id: "8"}]
My page_id
displays but not my content, it stays blank, how do I fix this?
The query:
$sql = "SELECT * FROM `cms_page` WHERE page_id = 8";
When i do echo $row["content"]
it actually shows me some content, its a string. The problem is the echo json_encode("data" => $row["content"]
its blank
SOLUTION:
I fixed that problem by encoding my string to UTF-8 with:
echo json_encode(utf8_encode($row["content"]));