It's your use of double quotes!
You are setting the $sql variable by using double quotes, and yet inside that variable you are using double quotes. This is breaking the $sql var
And check the string near the end. You have double quotes " at the beginning but at the end of the line you are using two single quotes to make it look like a double quote  '+' is showing as '' (run the cursors through each mark and you'll see what I mean).
|