|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
||||
|
||||
|
Perl mysql_escape_string equivalent
I have a saved HTML page stored in a variable. I want to copy this data into my database. The problem is, MySQL throws an error complaining that the data isn't escaped due to ""s. I would use PHP, but the existing script is quite large (>11,000 lines) and already in Perl. Is there a function similar to mysql_escape_string which escapes unescaped strings, or maybe a commonly used regex which does this? Thanks
__________________
"Java makes impossible things possible, but makes easy things difficult." - Somebody
|
|
#2
|
||||
|
||||
|
Perl actually has something way better. It is a concept called placeholders. Simply google or search this forum for "DBI placeholders".
For one thing, you don't need to call mysql_escape_string(), oracle_escape_string(), mssql_escape_string() or whatever for every database engine, since it automatically knows how to escape the string for every engine. On top of that, it runs a bit faster in loops since the database engine isn't recompiling the statement every time.
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
|
#4
|
||||
|
||||
|
Placeholders are a far better solution than escaped strings.
If you must do it that way, I'd use the quote method: Code:
my $quoted = $dbh->quote( $unquoted );
__________________
~ishnid; Have you tried: [ search.cpan.org | perldoc | Java API | mysql.com | google ] Apostrophes are NOT used for possessive pronouns or for noun plurals, including acronyms. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Perl mysql_escape_string equivalent |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|