Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting plus (+) symbols in query string

    Hello,
    I'm trying to grab a query string value for "search" where there are multiple values separated by plus symbols

    e.g. index.php?search=one+two+three


    in index.php I have the following

    $action = $_GET['search'];

    and I use this to do this

    require("http://www.mysite.com/cgi-bin/search.pl?search=$action");

    It works fine if there is only one search term. However when there is more than one the "require" breaks because it replaces the "+" with a blank space

    require("http://www.mysite.com/cgi-bin/search.pl?search=one"); (works)

    require("http://www.mysite.com/cgi-bin/search.pl?search=one two three"); (does not work)

    Is there a simple solution?

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,049
    Thanks
    2
    Thanked 317 Times in 309 Posts
    The urlencode() function will probably do what you want.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    New Coder
    Join Date
    Aug 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thankyou CFMaBiSmAd,
    That was a simple solution!

    $action = urlencode($action);


  •  

    Posting Permissions

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