apostrophe madness

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • S. Rhodes

    apostrophe madness

    Hello everyone.

    I am TOTALLY baffled. PLEASE, I need some help here.

    In the event that one must deal with a name including an apostrophe...I am
    looking for an appropriate solution.

    The flow of data is that the name is entered in via a form text box, stored
    in a MySQL table and then read back into another form or echoed out as
    needed.

    The problem that I am trying to overcome is what happens when an apostrophe
    is used in a name, i.e. D'linda.

    When I pull the information from the table and try to insert into a text box
    on a form, I only get D. No 'linda.

    I have tried escaping it, i.e. D\'linda and tried all the variations of ',"
    and '".???."' that I can think of. The challenge is placing the name in
    this text box:
    <input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
    In the above code, D'linda is stored in $row[addr].

    ALL input is most certainly appreciated!
    - Steven


  • Ian.H [dS]

    #2
    Re: apostrophe madness

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Whilst lounging around on Sun, 29 Jun 2003 16:57:52 -0700, "S.
    Rhodes" <steven_rhodes@ consultant.com> amazingly managed to produce
    the following with their Etch-A-Sketch:
    [color=blue]
    > Hello everyone.
    >
    > I am TOTALLY baffled. PLEASE, I need some help here.
    >
    > In the event that one must deal with a name including an
    > apostrophe...I am looking for an appropriate solution.
    >
    > The flow of data is that the name is entered in via a form text
    > box, stored in a MySQL table and then read back into another form
    > or echoed out as needed.
    >
    > The problem that I am trying to overcome is what happens when an
    > apostrophe is used in a name, i.e. D'linda.
    >
    > When I pull the information from the table and try to insert into a
    > text box on a form, I only get D. No 'linda.
    >
    > I have tried escaping it, i.e. D\'linda and tried all the
    > variations of '," and '".???."' that I can think of. The challenge
    > is placing the name in this text box:
    > <input type=text name=addr size=30 maxlength=30
    > value='".$row[addr]."'> In the above code, D'linda is stored in
    > $row[addr].
    >
    > ALL input is most certainly appreciated!
    > - Steven
    >[/color]


    $string = stripslashes($s tring);



    HTH.



    Regards,

    Ian

    -----BEGIN PGP SIGNATURE-----
    Version: PGP 8.0

    iQA/AwUBPv+G5Wfqtj2 51CDhEQKKRwCeOf ClskuNwBvWcmzGC dpIF1gohAwAoKS5
    2TflUjWihln7fTS m8dQHVr85
    =9oC8
    -----END PGP SIGNATURE-----

    --
    Ian.H [Design & Development]
    digiServ Network - Web solutions
    www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
    Programming, Web design, development & hosting.

    Comment

    • Geoff Berrow

      #3
      Re: apostrophe madness

      Message-ID: <vfuv6mhhik0r64 @corp.supernews .com> from S. Rhodes contained
      the following:
      [color=blue]
      >I have tried escaping it, i.e. D\'linda and tried all the variations of ',"
      >and '".???."' that I can think of. The challenge is placing the name in
      >this text box:
      ><input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
      >In the above code, D'linda is stored in $row[addr].
      >
      >ALL input is most certainly appreciated![/color]

      Have you got magic quotes turned on? I don't get this problem with my test
      database and it's pretty bog standard tutorial stuff.


      --
      Geoff Berrow
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • James Sleeman

        #4
        Re: apostrophe madness

        S. Rhodes wrote:
        [color=blue]
        > <input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
        > In the above code, D'linda is stored in $row[addr].[/color]

        Use <input type=text name=addr size=30 maxlength=30
        value=\"".htmls pecialchars($ro w[addr])."\">

        --
        James Sleeman
        Gogo:Code http://www.gogo.co.nz/
        Email domain : gogo.co.nz see user in from header!

        Comment

        • James

          #5
          Re: apostrophe madness

          On Mon, 30 Jun 2003 18:20:18 +1200, James Sleeman
          <james@seeMessa geForDomain.moc > scrawled:
          [color=blue]
          >S. Rhodes wrote:
          >[color=green]
          >> <input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
          >> In the above code, D'linda is stored in $row[addr].[/color]
          >
          >Use <input type=text name=addr size=30 maxlength=30
          >value=\"".html specialchars($r ow[addr])."\">
          >[/color]

          Use PHP as it's supposed to, and don't just "print" everything...
          then you can produce good HTML....

          ?>
          <input type="text" name="addr" size="30" maxlength="30"
          value="<?= htmlspecialchar s( $row["addr"] )?>" />
          <?

          Comment

          • S. Rhodes

            #6
            Re: apostrophe madness

            Thank you one and all for your suggestions! I appreciate your input.

            Due to Magic Quotes (runtime level) being turn off on the Server that host's
            my page, I am not able to benefit from that feature as I do not know of a
            way to turn them on from a PHP script.

            After reading all of the responses and trying all that was offered, I ended
            up with the following:

            echo "<td><input type=text name=paddr1 size=30 maxlength=30
            value=\"".htmls pecialchars($ro w[paddr1])."\"></td></tr>";

            This is doing the job, as far as populating the box appropriately.

            Again, THANK YOU one and all!

            - Steven


            Comment

            • tranceport technology group

              #7
              Re: apostrophe madness

              Hello,

              remember a few points . it is not xhtml compliant to write html code
              that doesnt include "" in it.. <img cellpadding="0" /> is valid xhtml
              as <img cellpadding=0 /> is not.

              in php print will interp. anything between " " looking for $variables
              echo does not. this is slower than using echo and concatinating.

              yeah its neat to break up your <? php open and closing tags.. but
              sometimes this gets annoying. so my suggestion is something like this:

              echo '<input type="text" name="addr" size="30" maxlength="30"
              value="'.$row['addr'].'" />';

              and please for the love of god its $row['addr'] not $row[addr]

              i hope this was helpful :)

              - Jonathan P Dryhurst Roberts

              newsgroup@black-panther.freeser ve.co.uk (James) wrote in message news:<3effdcaf. 368360604@news. freeserve.com>. ..[color=blue]
              > On Mon, 30 Jun 2003 18:20:18 +1200, James Sleeman
              > <james@seeMessa geForDomain.moc > scrawled:
              >[color=green]
              > >S. Rhodes wrote:
              > >[color=darkred]
              > >> <input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
              > >> In the above code, D'linda is stored in $row[addr].[/color]
              > >
              > >Use <input type=text name=addr size=30 maxlength=30
              > >value=\"".html specialchars($r ow[addr])."\">
              > >[/color]
              >
              > Use PHP as it's supposed to, and don't just "print" everything...
              > then you can produce good HTML....
              >
              > ?>
              > <input type="text" name="addr" size="30" maxlength="30"
              > value="<?= htmlspecialchar s( $row["addr"] )?>" />
              > <?[/color]

              Comment

              Working...