Agreed - try to think of it as a filter and less of something that needs to be computed both ways... much easier in the long run, and more efficient :) On 2/7/06, Curt Zirzow <czirzow@xxxxxxxxx> wrote: > > On Tue, Feb 07, 2006 at 10:38:37AM -0800, Sam Smith wrote: > > > > From a <textarea> on a web form I'm attempting to convert all > returns(\r), > > from the users input, to "<br />", for db INSERT, and then back again > for > > display in the <textarea>. (They remain as <br />s for normal HTML web > page > > display.) > > You really shouldnt convert the data to br's into the database, > just do it at the time at displaying it in html, and keep the raw > data in the database. > > // add to database (prepare avoiding sql injection) > $field = mysql_real_escape_string($_POST['textarea']); > $sql = "update jobs set jbs_jobDesA = '$field' WHERE jbs_ID=77"; > > // output to html, removing xxs ablity and add html br's > $field_from_db = $row['jbs_jobDesA']; > echo "<div>" . nl2br(htmlentities($field_from_db)) . "</div>"; > > // output to a textarea, removing xxs ability > $field_from_db = $row['jbs_jobDesA']; > echo "<textarea>" . htmlentities($field_from_db) . "</textarea>"; > > This would work much nicer. No need to do any two-way convertion of > your data. > > Curt. > -- > cat .signature: No such file or directory > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >