Jump to content

[SOLVED] strip new line tags


helraizer

Recommended Posts

Hi folks,

 

I have a comment form with textarea, but since the comments go onto an image I don't want them to be able to enter a carriage return/new line.

 

I've tried this:

 

$text = mysql_real_escape_string(htmlspecialchars(stripcslashes(substr($_POST['input'],
                    0, $rowing['char_count']))));
$text = mysql_real_escape_string(stripcslashes(nl2br($text)));
$text = mysql_real_escape_string(stripcslashes(str_replace("<br>", " ", $text)));

 

That, to me get's the truncated message (just incase it's over the character limit), which works. Then it should turn all new lines to a <br> tag then strip said tag. However it still adds the new line.

 

How else could I strip any new line feeds from the $text value?

 

Sam

 

 

Link to comment
https://forums.phpfreaks.com/topic/109732-solved-strip-new-line-tags/
Share on other sites

showimage_a.php5?uid=22&page=1

 

Each comment is added on one line. However if you add a comment with a carriage return (press enter in the textarea) then it writes it like this:

 

helraizer3.png

 

The comment was

 

"new

 

line

 

feed"

 

As you can see, the new is on the line it's supposed to be; then the 'line' is under the third comment and 'feed' is under the 5th.

 

Is it possible to strip the new lines that it's read "New Line Feed" all on one line, even if they added the carriage returns?

 

Hope that makes sense,

 

Sam

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.