swapped out mysql_real_escape_string for custom escape function due to mysql socket errors in non-DB connected code.