Hey I have a script which is attempting to read data from a mysql query into an array.
This array will then be looped through and each value output.
However I’m running into the following error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in C:wampwwwblogtester.php on line 14
Can anyone help me out.
Here is my code:
[code]
<?php
include (“config.php”); // includes db connection info and creates connection
$query = “SELECT name, email, comment FROM comments”;
$result = mysql_query($query) or die (“MySQL Error: Can’t run query: $query”);
$row = mysql_fetch_assoc($result);
$commentArray = array(); // Initialise array
while ($row ) // While $row exists read value into array $commentArray
{
$comment = $row[‘name’];
array_push($commentArray, $comment);
}
return $commentArray;
foreach ($commentArray as $value) { // Output each value in array.
echo $value . ‘<br />’;
}
?>