FYI db->query is depreciated as of 3.6. You should be using db->query_read and db->query_write. Not that this changes functionality but sticks with the vBulletin coding style.
I also noticed that you don't free the result of the database queries with db->free_result. db->query_first should be used in a number of places since you only want the value of one field. This will make remove the need for db->fetch_array and db->free_result.
Please use db->escape_string instead of addslashes. addslashes doesn't catch all cases nor does it take into account the SQL connection encoding.
For the datediff consider db->query_first_slave as we don't need to be hitting the master db server with that query.
|