Re: nl2br and BLOB field of MySQL
[email protected] ("John W. Long") Fri, 6 Sep 2002 13:55:44 -0400
| Newsgroups | php.lang |
|---|---|
| Message-ID | <[email protected]> |
Hi Jorge,
I think the answer lies in how you are posting a new record to your MySQL
table. Try applying nl2br before you post the new record instead of when you
are displaying the record.
I use the following code in conjunction with an odbc database to post my
record:
$Message = str_replace(array("\'",'\"'),array("''","\""),$Message);
$Message = nl2br($Message);
$SQL_Exec_String = "Insert Into Messages
(ReplyID,Subject,Sender,Email,Message,Reviewed)
Values ($ReplyID,'$Subject','$Sender','$Email','$Message',$Reviewed)";
$cur = odbc_exec( $cnx, $SQL_Exec_String );
The str_replace statement is used to handle the quotes and single quotes
**in the sql statement**. There may be a more elegant solution, but I'm new
to php as well.
___________________
John Long
www.wiseheart.20m.com
"Jorge Pinto Leite" <[email protected]> wrote in message
news:[email protected]...
> It's probably a problem of my code, can anyone help me?
> I have a BLOB field in a MySQL table. This field is filled in a php page
> with a <textarea>, where I can enter it formatted, with ENTER's to split
> some lines from others.
> In another page, this field is seen (not updated) - so I don't have a
> <textarea> tag.
> As I want to see the text exactly as entered, I have put the following
code:
> $res="<td><font...";
> $res.=nl2br($row[blobfield]);
> $res.="</font></td>";
> echo ($res);
> and the result is that I cannot see any part of the blob field.
> If I change my code to
> $res="<td><font...";
> $res.=$row[blobfield];
> $res.="</font></td>";
> echo ($res);
> the complete blob field is seen, yet unformatted.
> What am I doing wrong?
> Thanks,
> Jorge
>
>