I don't think it is a problem with the word LIMIT but the fact that you break up the SQL statement (string) on the previous line. It is no longer recognised as part of a SQL statement, and just considered as quoted text.
If you apply (int) to $y before creating the SQL then you can create the statement as one continuous string (with embedded variables). Alternatively, using sprintf() or prepared statements may also get around this niggle.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.