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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.