<?php
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
if((@$_GET['query']))
{
$query = @$_GET['query'];
$mysqli = new mysqli('localhost', 'johan', 'johan', 'fysiosteo');
$myArray = array();
if ($result = $mysqli->query("SELECT id, post_name FROM wp_posts WHERE post_type = 'page' AND post_content like '%" . $query . "%'")) {
$tempArray = array();
while($row = $result->fetch_object()) {
$tempArray = $row;
array_push($myArray, $tempArray);
}
echo json_encode($myArray);
}
$result->close();
$mysqli->close();
}
?>
Here is my service.php file. When i run this query in phpmyadmin, i get the results i want. But when i call it from another page using an ajax call, the pages content, post_content, gets the value null instead of the text on the page. Is it because of the html tags? Or what might be causing this? Thanks
The problem was encoding-related. UTF8 solved it.