ben9292 Posted November 26, 2010 Share Posted November 26, 2010 So I'm querying my database to add the results (mapID's) into a PHP array. The MySQL query I used in the below code would usually return 10 values (only 10 mapID's in the database) while($data = mysql_fetch_array(mysql_query("SELECT mapID FROM maps"))){ $sqlsearchdata[] = $data['mapID']; } Instead the page takes ages to load then gives this error: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 16 bytes) It says the error begins on the first line of the above code. I'm assuming this is not the right way to add the value from the MySQL array into a normal PHP array. Can anyone help me? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 26, 2010 Share Posted November 26, 2010 How large are these fields you're trying to store in the array? Quote Link to comment Share on other sites More sharing options...
ben9292 Posted November 26, 2010 Author Share Posted November 26, 2010 TINYINT[2] the mapID's are just 1-2 digit integers Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 26, 2010 Share Posted November 26, 2010 Just tested it locally, and building the whole query in the while() loop is cratering it. This should run fine $query = "SELECT mapID FROM maps"; $result = mysql_query( $query ) or die(mysql_error()); while( $array = mysql_fetch_assoc($result) ){ $sqlsearchdata[] = $array['mapID']; } Quote Link to comment Share on other sites More sharing options...
ben9292 Posted November 26, 2010 Author Share Posted November 26, 2010 ah ok... didn't think of that. Thank you very much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.