mysql_* to PDO update

Refactored code to use PDO instead of mysql_* functions to prevent SQL Injection.