Re: nl2br and BLOB field of MySQL

From: Date: Fri, 06 Sep 2002 17:55:44 +0000
Subject: Re: nl2br and BLOB field of MySQL
References: 1  Groups: php.lang 
Request: Send a blank email to php-lang+get-380@lists.php.net to get a copy of this message
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" <jpleite@ip.pt> wrote in message news:20020830223435.8041.qmail@pb1.pair.com... > 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 > >

« previous php.lang (#380) next »