You can't use that comma in PHP to concat strings. That's just bad syntax. Not exactly sure what you're trying to do, but that's not the way to get it done.
Additionally you have scary security issues with this code.
I wouldn't write logs using fopen. You run the risk of a hacker creatively writing a request to have them write code which might get executed on your server. Best avoided in production code. Also it wouldn't scale, as writing logs to file will eat up cycles.
Also you have SQL injection issues with that SQL statement you wrote. You need to use placeholders.