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