I was getting that issue. I realized there was probably a special character that was causing the "while" statement to trip on the query result.
In my case I had a varchar field but I suppose it could happen with any char field.
select replace(replace(replace(replace(replace(replace(Content,char(146),' '),char(147),' '),char(148),' '),char(149),' '),char(150),' '),char(151),' ') from MyTable
Then I got all my results. Cannot claim if all the characters listed here caught everything (Note LF/0x0a works fine)
This was with the linux version of PHP.