Subject Re: [firebird-php] How to echo BLOB Text from firebird with LF+CR ?
Author Milan Babuskov
Hamacker wrote:
> I wrote a memo text input from text area and write is OK, but when I
> restore from PHP by :
> ibase_blob_echo($row->MEMO)
> Appear a long single line, all text without linefeed+CR.
>
> When I restore from database by Delphi Application, Text is OK, there
> are #10#13 (LF+CR) in every line.
> How Can I put text formated in my html page ?
>
> Variants that I tested :
> echo nl2br(ibase_blob_echo($row->MEMO));
> str_replace("\n","<br>",ibase_blob_echo($row->MEMO));
>
> but fail ever...
> Threre are any solution ?

None of this works because ibase_blob_echo itself outputs the text. It
returns true, so what you did was calling nl2br/str_replace with true
argument instead of text.

> ibase_blob_echo(nl2br($row->MEMO));

This returned other kind of error, since $row->MEMO is not a string, and
result of that is not a...huh. If you don't understand why this doesn't
work, you better go back to learning PHP basics ;)

Ok, now to the solution(s):

1. Don't use blob_echo at all. Use ibase_blob_get to load blob into PHP
string and then call nl2br on it.

OR

2. Use <PRE> html tag, which renders data the way it is, i.e. all
newlines are rendered as newlines.

HTH

--
Milan Babuskov
http://fbexport.sourceforge.net