fixed real_escape_string issue on $encoded_data variable