Skip to content

Instantly share code, notes, and snippets.

@bugi
bugi / escape4mysql.pl
Created June 30, 2011 21:46
escape string for sql (mysql specific)
sub escape4mysql {
#
# If you MUST construct sql, rather than use parameters via the
# api, you can use this function on STRINGS to avoid quote-hell sql
# injection attacks.
#
# One scenario is for constructing queries from spreadsheets, to be applied later in a batch.
#
# input: zero or more strings (undef is handled as null).