Jump to content

line breaks from textarea to database and then to display


Fostav

Recommended Posts

I am using a ready script, which includes account registration and a few functions. Users can edit a text area on their profile which is saved on a database, is a description for something.

Editing the template of my script/web i would like to make it, when a user writes for example:

One
Two
Three

to be displayed like this also cause right now its like

One Two Three

I'made a re-search on the file's and found out the followings:

$description_prepare = str_replace(array("\r\n", "\n", "\r"), ' ', $FORM['description']);
$TMPL['description'] = $DB->escape($description_prepare, 1);
$TMPL['description'] = $this->bad_words($TMPL['description']);
$TMPL['description'] = preg_replace('/[^A-Za-z0-9 .,\-]/', '', $TMPL['description']);

as you can see the script is replacing the line breaks with a space ' '. i removed this part completely and made it like

$TMPL['description'] = $DB->escape($FORM['description'], 1);
$TMPL['description'] = $this->bad_words($TMPL['description']);
$TMPL['description'] = preg_replace('/[^A-Za-z0-9 .,\-]/', '', $TMPL['description']);

but now when i am editing the description for example from

One Two Three

to

One
Two Three

i am getting back

Onern Two Three

How can i solve this? Any idea? Thanks in advance

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.