Just for fun, here is a fix to your function.
use strict; use warnings; my $message = q(O'REILLY); my $sql_message = sql_escape( $message); print "$sql_message"; sub sql_escape { my $text = shift; $text =~ s/'/\\'/g; $text =~ s/"/\\"/g; return $text; }
Use the module!
In reply to Re: Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0
by BillKSmith
in thread Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0
by lancer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |