More fixes for issue 30282

This commit fixes a load more db queries and also adds some try/catch tags in for the queries

Thought it would be easier to keep all the PR's for this one together so merging it into this branch rather than the main Joomla one in case you were wondering :)

Sorry its in two parts - had to come back to it cause wasn't seeing it at all for the last insert statement.