Jump to content

[SOLVED] Line return in text box


AshmanSNET

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/74151-solved-line-return-in-text-box/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.