Remove all null characters when quoting

Previous code only removes a null character from the end of a string (although the code doesn't work for me), while sending a null character at any position will brake a query.