your select needs to wind up looking something like this:
SELECT userid, filename, username
FROM photoplog_fileuploads
WHERE moderate = 0
AND username = 'Mary Ann'
ORDER BY RAND()
LIMIT 5
Which is why I asked you what the query looked like when you printed it out. Because I don't know what the rest of your code looks like, it could have been that the variable had single quote in it, or not.