pouncer Posted February 27, 2007 Share Posted February 27, 2007 $Desc = mysql_escape_string($_POST['txt_Description']); thats my description text box, which is what i insert into my sql table say if i enter my description like this: hello, these are my favourite dvd's !!!!! When i query my database to display it, it gives me: hello, these are my favourite dvd's!!!!! the exclamation marks should be on a new line right!??? $description = stripslashes($row['description']); thats how im getting it! echo $description; Quote Link to comment https://forums.phpfreaks.com/topic/40363-insertdisplay-problem/ Share on other sites More sharing options...
New Coder Posted February 27, 2007 Share Posted February 27, 2007 Have you tried? $description = $row['description']; What does strip slashes do? If you just want to clean the string up use $description = rtrim($row['description']); Hope this helps, but could be a mile off lol Quote Link to comment https://forums.phpfreaks.com/topic/40363-insertdisplay-problem/#findComment-195300 Share on other sites More sharing options...
itsmeArry Posted February 27, 2007 Share Posted February 27, 2007 instead of using mysql_escape_string($_POST['txt_Description']); covert the br to new line... like nl2br(mysql_escape_string($_POST['txt_Description'])); Quote Link to comment https://forums.phpfreaks.com/topic/40363-insertdisplay-problem/#findComment-195301 Share on other sites More sharing options...
pouncer Posted February 27, 2007 Author Share Posted February 27, 2007 to insert $Desc = nl2br(mysql_escape_string($_POST['txt_Description'])); i inserted it but still when i display it, it still not appearing on multiline (btw when i dislay it, its in a table like <td align=center bgcolor=#F5F5FF>$description</td> Quote Link to comment https://forums.phpfreaks.com/topic/40363-insertdisplay-problem/#findComment-195305 Share on other sites More sharing options...
pouncer Posted February 27, 2007 Author Share Posted February 27, 2007 anyone have any idea? Quote Link to comment https://forums.phpfreaks.com/topic/40363-insertdisplay-problem/#findComment-195336 Share on other sites More sharing options...
kenrbnsn Posted February 27, 2007 Share Posted February 27, 2007 Do not apply the nl2br() function when you insert the data into the database, only use it when you're displaying the data. Also you should be using the mysql_real_escape_string() function. One caveat, I have heard that the mysql_real_escape_string() function will convert the newline character "\n" to a plain string '\n' which the nl2br() function will not find. If this causes you problems, use something like this: <?php echo '<td align=center bgcolor=#F5F5FF>' . nl2br(str_replace('\n',"\n",$description)) . '</td>'; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/40363-insertdisplay-problem/#findComment-195347 Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 kenrbnsn here you are jus replacing \n with \n <?php echo '<td align=center bgcolor=#F5F5FF>' . nl2br(str_replace('\n',"\n",$description)) . '</td>'; ?> use this it will replace '\n' to "\n" <?php echo '<td align=center bgcolor=#F5F5FF>' . nl2br(str_replace("'\n'",'"\n"',$description)) . '</td>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/40363-insertdisplay-problem/#findComment-196741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.