Jump to content

Ampersand in querystring problems..


chelnov63

Recommended Posts

Hi when I pass a variable (which contains an ampersand) in a querystring it gives a problem..

 

example:

 

$company = "B & Q";
<a href='companies/edit_company_details.php?company=<?php echo $company; ?>'>click here </a>

 

 

but obviously the next page reads the company as being equal to 'B'

 

How do I get around this? Thanks in advance....

Link to comment
https://forums.phpfreaks.com/topic/152834-ampersand-in-querystring-problems/
Share on other sites

thank I actually tried that but it still doesnt work: this is the exact code:

 

<a href="javascript:popUp('companies/edit_company_details.php?company=<?php echo urlencode($company); ?>')"><?php echo $row["company"]; ?></a>

 

but when the new page opens the url in the top says:

 

http://localhost/companies/edit_company_details.php?company=B+&+Q+Plc

 

so it doesnt really look like its encoding the & symbol....

 

any ideas why this is so?

 

cheers

 

 

Thanks Ken unfortunately still not working..it's strange as if i create a new php file and use urlencode it works fine, but for some reason in my context it's not doing it... i ended up using a hack instead:

 

$company = str_replace("&", "|||", $company );

 

and then on the recieving page, i just reverse it:

 

$company = str_replace("|||", "&", $_POST["company"]);

 

thanks for your help anyway... cheers!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.