I know from the error message it is something to do with:
$query = $db->query($sql);
But I can't figure out what. I have done a few searches on google and not really found anything that is helpful to me. Can someone please provide me with a bit of guidance.