Forum Moderators: coopster

Message Too Old, No Replies

stops with a &

         

bodycount

3:27 pm on Apr 9, 2008 (gmt 0)

10+ Year Member



I was wondering if somebody could help with this problem

I have a link on one page with the company name when I click on the link the other page opens

this is what is in the http:// at the top of the page

"editaddress.php?COMPANY_id=Benley%20&%20Benley%20Marketing"

i am using the following

$COMPANY_id = (isset($_GET['COMPANY_id'])) ? $_GET['COMPANY_id'] : '';

but all I get returned is COMPANY_id = Benley where it should be COMPANY_id = Benley & Benley Marketing. I have other companys with just space's between the names they work fine but any company with a "&" in it stop at the & how do i stop it from stopping at the &.

Thanks

Rob.

PHP_Chimp

4:32 pm on Apr 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Although I dont know if this is actually your problem, but as you have encoded the space to %20, yet you have left the &. So either & or %26.

mehh

6:12 pm on Apr 9, 2008 (gmt 0)

10+ Year Member



The "&" symbol is used to signify a new variable, for example:

editaddress.php?COMPANY_ID=3&COMPANY_NAME=Benley%20&%20Benley%20Marketing

To use a "&" inside the variable you need to escape it to "%26", also I would recomend escaping the spaces to "+" rather than "%20" as it looks neater.

editaddress.php?COMPANY_id=Benley+%26+Benley+Marketing

mikhaill

5:33 am on Apr 10, 2008 (gmt 0)

10+ Year Member



The best option would be to use url_encode() on the company names and let PHP handle all the encoding logic, otherwise posters above me are 100% correct.

g1smd

1:03 am on Apr 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Spaces in URLs are generally not a good idea, and even stuff like %26 isn't that good either.

I'd try avoiding those.