Preserving user-entered linebreaks
Posted on
16th Feb 2014 07:03 pm by
admin
Hi, I'm building a web 2.0 thingy from scratch and I wanna display text which users input. It's all good so far, except that all the linebreaks are destroyed, so no matter how carefully they insert whitespace, their input gets displayed as one big block of text.
The data is submitted (method="post") through a textarea. The mysql_real_escape version is stored in mysql. Then it's read from the database (no unescaping necessary) and passed through htmlentities before being printed into the body of the webpage.
I tried replacing htmlentities with the following function:
Line number On/Off | Expand/Contractfunction brentities($x){ $x = str_replace("[LINEBREAK]","nr",$x); $x = str_replace("[LINEBREAK]","rn",$x); $x = str_replace("[LINEBREAK]","n",$x); $x = htmlentities($x); $x = str_replace("<pre>n</pre>","[LINEBREAK]",$x); return $x;}
But this doesn't seem to work. I also tried setting "white-space: pre;" in the CSS for the appropriate div, but that caused the text to bleed outside the div (and even outside the screen), so no go
What's the best way to settle this issue?
Thanks
No comments posted yet
Your Answer:
Login to answer
53
35
Other forums
php - xml what is the best way to do this.
IN essence I want to have a script calling the info from the database.. I have no problem thus far,
shift numbers with paging
Hi
How would i be able to display 10 numbers 1 2 3 4 5 6 7 8 9 10
and when I click next
php mailer
How can i send a mail to large no, say 50,000 reciepients using [color=#0000FF]php mailer[/color]
finding key position of specified value in multi-dimensional array
Code: $openedfile = fopen($tfc_file4, "r");
$rc = 1;
while(!feof($openedfile))
{<
need help in creating captcha
hi i have a problem creating captcha system. i create some basic script for image displaying but it
tag inside php... hi
Code: <?php echo "<td width="$columnWidth%" align=& WM transfer order: confirm different batch than proposed by system Hi folks,
following scenario: we have a full WM with mixed batch numbers allowed in stora CE 7.1 and External GIS integration Hi All,
We want to develop an application on CE 7.1 which uses GIS features from an exter Needing Youtube thumb nail fix. I have a script on a site that pulls in you-tube videos, The problem is, that the thumb nails for How to get exact 3 moths post date from today date using javascript How to get exact 3 moths post date from today date using javascript Please help
|