So what you have is a raw chunk of SQL text in the middle of your PHP code, without any of the following PHP code.
(Added syntax highlighting.)
The other error is using square brackets around column names, which is a SQL Server thing not (as far as I'm aware) recognised by MySQL. The standard method for quoting names (which is only necessary if the thing being quoted is something like a SQL keyword) is to use ""
but I don't remember if MySQL uses those either. But since user_id
is not an SQL keyword it doesn't need to be quoted at all.