I have a query which is supposed to retrieve data from mysql and print it on the browser. It is working with a few rows of data but when the data gets bigger it just stops working and doesn’t give any errors.
$result = mysql_query($query);
$json_array = array();
while($row = mysql_fetch_assoc($result)){
$json_array[] = $row;
}
print mysql_error();
print json_encode($json_array);
I have tried everything but nothing seems to work.
2
Answers
I’m very surprised it works at all.
This would work if $row was formatted.
Use
foreach()
I doubt this would work either:
This should work (replace colx with the name of the table columns):
@Lessmore has right, maybe the PHP process has reached the memory limits in the server, try with less columns or registers, but I understand your need, then you need to write your self json_encode code to write row by row. Some like this: