passing variable data containing + or %20

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ricnut
Forum Newbie
Posts: 10
Joined: Tue Nov 21, 2006 12:44 am

passing variable data containing + or %20

Post by ricnut »

Hi, I have one script which passes on a variable to another page, but it won't pass the plus sign on, even if I write it as %20.

Code: Select all

 
$text_input = "black+eyed";
 
print "
<a href=\"zoog10.php?my_variable=$text_input\">GO!</a>
";
 
 
My retrieving page

Code: Select all

 
 
$num = $_GET['my_variable'];
 
 
Is there any way to pass this + sign on? :P
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Re: passing variable data containing + or %20

Post by aaronhall »

%20 bes the space code point. Try %2B.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: passing variable data containing + or %20

Post by onion2k »

Better yet, try urlencode().
Post Reply