SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php echoing an initial value in a form

    I am setting up a page to edit existing mysql records. I have everything working except for one form feild where the text includes "quotation" marks. Using echo in the form feild it includes everything up to the first ".

    Note: I tried echoing the $size variable just on the page (ie not in the form feild) and it prints everything including the ".

    code for form is:

    <input type="Text" name="size" value="<?php echo $size ?>" size="30">

    Any help would be appreciated.

    Thanks

    JAF

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, of course the browser thinks that " is the ending " for the value="" attribute. just use htmlspecialchars():

    <input type="Text" name="size" value="<?php echo htmlspecialchars($size) ?>" size="30">
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    special character

    Thanks Dr Larry Pepper - the exact code that I got to work is:

    <?php echo htmlspecialchars($size); ?>

    That got it working.

    JAF


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •