"Hard return" causing hangups

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jimmy Clay (www.songofthecoyote.com)

    "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:


    Thanks for any help you can give.
    Jimmy

  • Peter van Schie

    #2
    Re: "Hard return" causing hangups

    Jimmy Clay (www.songofthecoyote.com) wrote:
    [color=blue]
    > 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.[/color]

    Something like this would do the trick:

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

    --

    Comment

    • Jimmy Clay (www.songofthecoyote.com)

      #3
      Re: "Hard return" causing hangups

      That worked. Thanks

      Comment

      • Toby Inkster

        #4
        Re: "Hard return" causing hangups

        Peter van Schie wrote:
        [color=blue]
        > $strMessage = preg_replace("/\n|\r\n|\r/", "", $strMessage);[/color]

        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

        Comment

        • Peter van Schie

          #5
          Re: "Hard return" causing hangups

          Toby Inkster wrote:[color=blue]
          > Peter van Schie wrote:
          >
          >[color=green]
          >>$strMessage = preg_replace("/\n|\r\n|\r/", "", $strMessage);[/color]
          >
          >
          > Isn't thie middle "\r\n" a bit redundant?
          >
          > $strMessage = preg_replace("/[\r\n]", "", $strMessage);
          >[/color]

          True, but it does exactly the same. :)

          --

          Comment

          Working...