Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
The stupid question is the question not asked
 
PerlMonks  

Re^2: Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0

by lancer (Beadle)
on Jul 26, 2012 at 17:50 UTC ( #983892=note: print w/ replies, xml ) Need Help??


in reply to Re: Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0
in thread Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0

Thanks for the suggestion, I was able to replace it with this:

sub sql_escape { my $text = shift; $text = DBD::_::db->quote ($text); return $text; }

Outputs: O''REILLY

(This format works with MySQL)


Comment on Re^2: Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0
Download Code
Re^3: Using regex to add a single backslash to escape quotes, instead of 2 backslashes or 0
by Corion (Pope) on Jul 26, 2012 at 18:26 UTC

    Why don't you use

    $dbh->quote(...)

    as the documentation suggests?

      I needed to convert a CSV file to SQL format (it would be later imported with phpMyAdmin). At the time of conversion there was no database to connect to, but a $dbh can be only created with a connection to a DB.

      Someone on StackOverflow suggested to use the above solution which works without a DB connection. ( http://stackoverflow.com/a/10458266 )

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://983892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-04-20 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls