471,071 Members | 5,747 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

"Hard return" causing hangups

On my website I have Guestmap that is written in PHP. I did not write
it but got it from a freeware site. Anyway it works well, except I've
discovered that if someone writes a message and uses the enter key,
that will hangup the GuestMap. There is no error message, the icons
simple will not load and no one else can enter a message.

My solution is to have PHP code remove all hard returns form the
strings before they are stored in the database. But I'm not sure what
the code would be for that. I'm sure it's easy but I don't actually
know much about PHP programming.

Anyway my website is:
www.songofthecoyote.com

Thanks for any help you can give.
Jimmy

Oct 30 '05 #1
4 1466
Jimmy Clay (www.songofthecoyote.com) wrote:
My solution is to have PHP code remove all hard returns form the
strings before they are stored in the database. But I'm not sure what
the code would be for that.


Something like this would do the trick:

$strMessage = preg_replace("/\n|\r\n|\r/", "", $strMessage);

--
http://www.phpforums.nl
Oct 30 '05 #2
That worked. Thanks

Oct 30 '05 #3
Peter van Schie wrote:
$strMessage = preg_replace("/\n|\r\n|\r/", "", $strMessage);


Isn't thie middle "\r\n" a bit redundant?

$strMessage = preg_replace("/[\r\n]", "", $strMessage);

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Oct 30 '05 #4
Toby Inkster wrote:
Peter van Schie wrote:

$strMessage = preg_replace("/\n|\r\n|\r/", "", $strMessage);

Isn't thie middle "\r\n" a bit redundant?

$strMessage = preg_replace("/[\r\n]", "", $strMessage);


True, but it does exactly the same. :)

--
http://www.phpforums.nl
Oct 30 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by yingjian.ma1955 | last post: by
10 posts views Thread by LaEisem | last post: by
4 posts views Thread by Gérard Talbot | last post: by
3 posts views Thread by (PeteCresswell) | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.