Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: replacing carriage return line feed usinf chr()

by Piercer (Beadle)
on Mar 14, 2003 at 17:45 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2023-10-04 16:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found