SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Volitics's Avatar
    Join Date
    Aug 2003
    Location
    US
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ampersand "&" char not working when in URL string variable.

    Hello;

    I'm trying to get the variable appended to the URL below to output into a text box on Page.php.

    It should output "jones & bones". Instead, it chops off the term beginning with the ampersand. It outputs only "jones".

    PHP Code:
    http://www.mydomain.com/Page.php?Name=jones%20&%20bones

    // ---- text input box on Page.php
    // trying to output the above variable $Name into text box below.
    <input type="text" name="Name" value="$Name">

    // Here's what it outputs
    <input type="text" name="Name" value="jones ">

    // I'm trying to get it to output this:
    <input type="text" name="Name" value="jones & bones">

    //I've tried enclosing the $Name variable in htmlspecialchars() like so:
    htmlspecialchars($Name)
    //or
    <input type="text" name="Name" value="htmlspecialchars($Name)">
    // but it still chops off the "& bones" part of the variable. 
    I can put the variable in a hidden field and convey it by a form post and it outputs in the text box just fine.
    PHP Code:
    // this works ok.
    <input type="hidden" name="Name" value="jones &amp; bones">

    // It outputs like I want it to on the next page.
    <input type="text" name="Name" value="jones & bones"
    I would appreciate if anyone could spot the problem.

    Thanks.

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Addict Volitics's Avatar
    Join Date
    Aug 2003
    Location
    US
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    patter,

    thanks for the help.


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
  •