Switching SQL queries to prepared statements

SELECT statements changed to prepared statements