序列化wordpress wp_posts ajax搜索,post_content = null


Serializing wordpress wp_posts for ajax search, post_content = null

<?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();
}
?>

这是我的service.php文件。当我在phpmyadmin运行此查询时,我得到了我想要的结果。但是当我使用ajax调用从另一个页面调用它时,页面内容,post_content,获得值null而不是页面上的文本。是因为html标签吗?或者是什么导致了这种情况?由于

try

while($row = mysql_fetch_array($result) {

您当前正在获取一个对象。

问题与编码有关。UTF8解决了