markkanning Posted November 8, 2006 Share Posted November 8, 2006 Okay, folks...here's the deal:I've got the classic replace "\n" with break tags when dumping <textarea> content into a database, and THEN returning it to an "Edit" <textarea> with the break tags replaced with "\n". I've been surfing for hours on this subject and can't find a solution that works. So, here's my code:The "insert" script:[code]<?php $id=$_POST['id']; $disp_ord=$_POST['disp_ord']; $name=$_POST['name']; $image=$_POST['image']; $bio=$_POST['bio']; $id = addslashes($id); $disp_ord = addslashes($disp_ord); $name = addslashes($name); $image = addslashes($image); $bio = nl2br($bio); include 'dbconnect.php'; $query = "insert into team (disp_ord, name, image, bio) values ('$disp_ord', '$name', '$image', '$bio')"; $result = mysql_query($query); if ($result) { header("Location: vieweditteam.php"); }?>[/code]Notice I'm using [i]$bio = nl2br($bio);[/i] which is the <textarea> in question. It does exactly what I've read it should do, so no problems there. Here's the "view/edit" page code:[code]<?php include 'dbconnect.php'; $query = "select * from team order by disp_ord"; $result = mysql_query($query); $num_results = mysql_num_rows($result); for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo "<form action=updatemember.php method=post name=updatemember> <textarea>".stripslashes($row["bio"])."</textarea> </form>"; }?>[/code]Notice the "bio" reference:[i]stripslashes($row["bio"])[/i]. This returns the text content with the break tags that the nl2br replaced. So, the ultimate question is what method do I use to get the <textarea> back to the proper non-break-tag state. I'm aware of the br2nl() thing and the str_replace thing, but how do I implement any of them in this context?HELP ME!!!!!!!!!!!!!Mark Link to comment https://forums.phpfreaks.com/topic/26541-a-nl2brbr2nl-problemhelp/ Share on other sites More sharing options...
Jenk Posted November 8, 2006 Share Posted November 8, 2006 strig_tags() Link to comment https://forums.phpfreaks.com/topic/26541-a-nl2brbr2nl-problemhelp/#findComment-121446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.