We need to see the database error to see the problem... all I can see is "Invalid SQL" which means something in the code is wrong, the database is likely fine.
To start take a screen shot with the page scrolled to the bottom or copy and paste the full text of the SQL error so we can have an idea of what is wrong.