updated $rid to $result_id
it's result_id everywhere in the database, so let's stay consistent (result_id vs rid), fixed a couple notices