Is there a function i can use in Perl to sanitize input before putting it into a MySQL db? I don’t know regex very well so before I make my own function i was wondering if there was already one made.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The proper way to sanitize data for insertion into your database is to use placeholders for all variables to be inserted into your SQL strings. In other words, NEVER do this:
Instead, use
?placeholders:And then pass the variables to be replaced when you execute the query:
You can combine these operations with some of the DBI convenience methods; the above can also be written:
See the DBI docs for more information.