Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: replacing carriage return line feed usinf chr()

by Piercer (Beadle)
on Mar 14, 2003 at 17:45 UTC ( [id://243129]=note: print w/replies, xml ) Need Help??


in reply to replacing carriage return line feed usinf chr()

Many thanks to all who replied - I eventually found a way to do it using split and join. This worked for me....
$a = "\'aaaaa\nbbbbbb\'"; $a = join ('\' + Chr(13) + Chr(10) + \'', split(/\n/, $a)); $sql="insert into KB (Description) values ($a)";
Cheers all.

Replies are listed 'Best First'.
Re: Re: replacing carriage return line feed usinf chr()
by thraxil (Prior) on Mar 14, 2003 at 19:22 UTC

    you really, really should follow jeffa's advice and use DBI's placeholders to handle this kind of thing. your solution handles \r and \n but if $a has a ')' or a quote or any other weird character that you haven't accounted for, it will still break. your solution at best is fragile and at worst could become a security hole. placeholders are the Right ThingTM.

    anders pearson

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found