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

"\r" is interpolated as chr(13) and "\n" is chr(10). You should be able to do something like this:
$sql = "insert into test (field1) value 'aaaaaaa\r\nbbbb'";

-Matt