passing string with spaces via url

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
sarris
Forum Contributor
Posts: 137
Joined: Mon Dec 04, 2006 2:44 pm

passing string with spaces via url

Post by sarris »

Hi there.
I have this string that i obtain from a database, $address.
I want to pass that via url,

Code: Select all

$html_block .= "<a href=printableTemplate.php?address=$ad&size=$size>Create Printable Template</a>";
$html_block is a string that keeps html code, to be echoed in the <body> section of the html...

The url created created for that link, if address is for example "SomestreetName 45" is

http://www.mysite.com/printableTemplate ... streetName

The number is not passed and not is the size parameter...
Anyone knows how to solve this?
thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  1. Your anchor tag's href attribute lacks quotes.
  2. the data should be passed through rawurlencode() at minimum.
sarris
Forum Contributor
Posts: 137
Joined: Mon Dec 04, 2006 2:44 pm

Post by sarris »

very well...thank you!!!
Post Reply