AshmanSNET Posted October 21, 2007 Share Posted October 21, 2007 G'day, I have a text box where users type whatever. Anyways, I am using stripslashes() and posting the contents to mysql table as TEXT. Every where I have used br it echos the newline plus rn, which i assume is supposed to be \r\n with the slashes removed. So I don't have to input br everytime I press enter, how can I catch when the enter key is pressed and output a new line, like the way this forum is doing it? Thanks Ashman Quote Link to comment https://forums.phpfreaks.com/topic/74151-solved-line-return-in-text-box/ Share on other sites More sharing options...
pocobueno1388 Posted October 21, 2007 Share Posted October 21, 2007 nl2br() www.php.net/nl2br Quote Link to comment https://forums.phpfreaks.com/topic/74151-solved-line-return-in-text-box/#findComment-374470 Share on other sites More sharing options...
Wes1890 Posted October 21, 2007 Share Posted October 21, 2007 Always read the manual! http://us.php.net/nl2br [edit]weird... same replies lol Quote Link to comment https://forums.phpfreaks.com/topic/74151-solved-line-return-in-text-box/#findComment-374473 Share on other sites More sharing options...
AshmanSNET Posted October 21, 2007 Author Share Posted October 21, 2007 I tried using nl2br() earlier with the same problem.... turns out it doesn't work with mysql_escape_real_string(). I had: $sMessage = mysql_escape_real_string($_POST['sMessage']); $sMessage = nl2br($sMessage); Works now. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/74151-solved-line-return-in-text-box/#findComment-374476 Share on other sites More sharing options...
Wes1890 Posted October 21, 2007 Share Posted October 21, 2007 ^ yeah.. well we cant read your mind, so post your script next time Quote Link to comment https://forums.phpfreaks.com/topic/74151-solved-line-return-in-text-box/#findComment-374477 Share on other sites More sharing options...
wildteen88 Posted October 21, 2007 Share Posted October 21, 2007 I tried using nl2br() earlier with the same problem.... turns out it doesn't work with mysql_escape_real_string(). I had: $sMessage = mysql_escape_real_string($_POST['sMessage']); $sMessage = nl2br($sMessage); Works now. Thanks If you are using nl2br when inserting data into a database then don't. It is best to use nl2br when you pull data out of the database. Quote Link to comment https://forums.phpfreaks.com/topic/74151-solved-line-return-in-text-box/#findComment-374712 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.