some changed from mysql to pdo::query and fixed 2 problems