|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
escaping illegal characters for MySQL with perl
I'm a newbie...
coded a little perl script to post form data to MySQL database. I'm wondering if I need to add any perl code to the posted data that will escape any illegal characters before it gets written to the database. Is there standard code already written for this purpose? Sorry if this has been covered. i searched and didn't come up with anything. thanks! |
|
#2
|
||||
|
||||
|
I assume that your using DBI to access the db. Try using DBI's $dbh ->quote();, or use place holders.
Mickalo
__________________
Thunder Rain Internet Publishing Custom Programming & Database development Providing Personal/Business Internet Solutions that work! |
|
#3
|
|||
|
|||
|
Yes, you should always use dbi and the quote() or place holders method. If you're using something other then dbi (first of all, you'd be a fool
), you could just use a regex to do it (note: all this does it backtick '):Code:
$var =~ s|'|\\'|g; |
|
#4
|
|||
|
|||
|
Thanks for the replies. Unfortunately I'm not 100% sure how this works, and can't seem to find more information on it's use. Do you just re-assign the variable like this, or is it different?
$var = "big mamma's house"; $var = $dbh->quote($var); Thanks again! Rory |
|
#5
|
|||
|
|||
|
Yes, that is the correct usage.
__________________
Jon Coulter ledjon@ledjon.com |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > escaping illegal characters for MySQL with perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|