Use $modx->db->escape() instead mysql_real_escape_string()