I am trying to json_encode the following mysqli results. My issue is after adding each row to my array I am unable to 'echo json_encode' my array but I am able to print_r the array. If I add a limit to this particular query then echo json_encode works but that limit is 313. I thought that indicated a php memory limit issue but after changing my memory_limit to 256M I am still only able to return the same amount of data. I've tried searching for similar issues but nothing was close enough to the issue I'm facing. My entire php script is pasted below. Any advice is appreciated.
<?php
if(isset($_GET["table"])){
// Open db connection
require "opendb.php";
/*** $table = assay ***/
$table = $_GET["table"];
$query = "SELECT * FROM invitrodb_v1.{$table}";
// Store results from query
$data = mysqli_query($conn, $query);
$table_row = array();
while($row = mysqli_fetch_array($data)){
$table_row[] = $row;
}
/**
*
*print_r displays array contents
*echo json_encode does not
*
**/
//echo json_encode($table_row);
//print_r($table_row);
// Close db connection
require "closedb.php";
}
//***342 rows returned with the assay table when not limited***//
?>
edit: This is an example of what I am returning. For this specific table there are 342 rows that are similar to this..fyi this is data from a public database found here http://www.epa.gov/ncct/toxcast/data.html (in case anyone is curious).
{
"aid": "1",
"asid": "1",
"assay_name": "ACEA_T47D",
"assay_desc": "ACEA_T47D is a cell-based single readout assay using T47D human breast cell line at 80 hours in a 96-well plate.",
"timepoint_hr": "80",
"organism_id": "9606",
"organism": "human",
"tissue": "breast",
"cell_format": "cell line",
"cell_free_component_source": "NA",
"cell_short_name": "T47D",
"cell_growth_mode": "adherent",
"assay_footprint": "microplate: 96-well plate",
"assay_format_type": "cell-based",
"assay_format_type_sub": "cell-based format",
"content_readout_type": "simple",
"dilution_solvent": "DMSO",
"dilution_solvent_percent_max": "0.5"
}