RE: [PHP] Problems with user's newlines

From: Date: Mon, 10 Jul 2000 20:41:04 +0000
Subject: RE: [PHP] Problems with user's newlines
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5806@lists.php.net to get a copy of this message
> I am using Php3, JavaScript, and mysql on my site. I have a textbox >that users can fill in; this is stored in a database. Later, this >information will be redisplayed in a web page. The way the webpage is >generated is by using php to generate javascript which generates html. >It works fine unless the user puts in a newline. Then javascript >complains that the lines are not terminated. But I have been trying to >do ereg_replace on the strings: >$string = ereg_replace("\n","<BR>",$string); >I'm getting the <BR>'s, but still the newlines seem to be there. I >tried matching on "\\\n" and got the same result. Does anyone have any >ideas why this match is not working? I don't know why this should not work; but you could try the nl2br function. It does what you want. Good Luck, Jeroen

« previous php.general (#5806) next »