MySQL: mysql_fetch_assoc dies out before retrieving all records

I have a mysql table (with 8,316 rows) I’m trying to output to an array in PHP, but it times out (at around 8,058 to 8,060 rows). Anyone know how to resolve this:

Here’s my environment:
PHP 5.3.3, Linux host, MySQL 5.1.61

Here’s my code:

mysql_select_db($database, $connection);
$query_rs_data = sprintf(" SELECT * FROM my_table ");
$rs_data = mysql_query($query_rs_data, $connection) or die(mysql_error());
$row_rs_data = mysql_fetch_assoc($rs_data);
$totalRows_rs_data = mysql_num_rows($rs_data);

echo $totalRows_rs_data;

$my_array = array();
$count = 0;
do {
	$count = $count + 1;
	echo $count . "<br/>";
	$my_array[$row_rs_data['id']] = $row_rs_data;
} while ($row_rs_data = mysql_fetch_assoc($rs_data));

Never mind.

Found out is was a “Fatal Error: Allowed memory size of X bytes exhausted” error. So I just increased the php.ini memory_limit.

Problem fixed.

Try reducing the number of columns returned if possible when dealing with recordsets of this size. Also, PEAR has a streaming tool for large recordsets you may want to look into.

Thanks for the tips. If the problem comes up again, I’ll look into them.