doulun1939 2016-11-15 14:31
浏览 126

换行从textarea到数据库然后再显示

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("
", "
", ""), ' ', $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 help or advice is appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了