Reputation: 7330
I've a table with content pulled from a pdf file page wise (separate row for each page). It works fine but some of my results are returned as null even though the content exists in the table row? Why some are returning as null?
$q = isset($_REQUEST['q']) && $_REQUEST['q'] != "" ? $_REQUEST['q'] : null;
$statement = $this->connection->prepare("SELECT number, content FROM page WHERE folio_id = :folio_id AND content LIKE :q");
$statement->setFetchMode(\PDO::FETCH_CLASS, get_class(new PageVO()));
if($statement->execute(array("folio_id" => $folio_id, "q" => "%" . $q . "%"))) {
return $statement->fetchAll();
}
in my output file
header('Content-type: application/json');
echo json_encode(array("search" => $searchVO));
Screenshot attached.
After Adding Length Attribute
Upvotes: 1
Views: 813
Reputation: 254896
It happens because some of your strings are not properly utf-8
encoded.
In that case json_encode
returns null
.
Upvotes: 2