(!empty($db->sql_affectedrows()))
This type of logic isn't working in < PHP 5.5. Results in "PHP Fatal error:  Can't use method return value in write context"

Same for all similar occurrences below