1. Do CHECK TABLE for all tables with phpmyadmin. If you see corrupted .MYI files repair those tables at least twice (yes!).
2. if above does not help, increase max temporary table size in my.cnf, e.g. : tmp_table_size=128M
3. check mysql error log for clues
4. Again, the result set must fit into php memory, if you do SELECT * make sure you know how much data you get.