Re: Help with '&' character
| From: | André Cerqueira | Date: | Tue, 17 Feb 2004 17:50:31 +0000 |
| Subject: | Re: Help with '&' character | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177992@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
http://...&campaign=MBI%20List%20-%20Steel%20&%20Concrete (wrong)
http://...&campaign=MBI%20List%20-%20Steel%20%26%20Concrete (right)
where does that url come from?
is it generated by a script?
if it is, you must urlencode() it before outputing, not when receiving it from a request
query string works like this...
you have name and value of each field separated with '=', and each field separated with '&' from another field
ex.: name1=value1&name2=value2
this means that if you have an '=' on the string, IT IS separating a name from a value, and if you have a '&' on the string, IT IS separating a field from another one
no matter what you want the '=' or the '&' to be, they already are something
urlencode each piece (urlencode($fieldname) and urlencode($fieldvalue)), before separating them with '=' and '&', those and other characters will be substituted by something that will tell what they really are
as well as that %20 is a urlencoded <space>...
Chris Bruce wrote:
I am having trouble with a string becoming truncated at an '&' character. I am passing the variable via a link (http://...&campaign=MBI%20List%20-%20Steel%20&%20Concrete) and then when I try to grab the incoming value of campaign into a SELECT query, it becomes SELECT sum(sends) from campaigns where name='MBI List - Steel ' I have tried to urlencode the variable, and also use htmlentities, etc. to no avail. Does anyone have a solution for this? Thanks. -- Chris Bruce chris@idextrus.com Idextrus E-Business Architects http://www.idextrus.com 3282 Wilmar Cres. Mississauga, ON L5L4B2 CA 905.828.9189 **************************************************************** This e-mail and its contents are privileged, confidential and subject to copyright. If you are not the intended recipient, please delete this e-mail immediately. Any unauthorized use or disclosure of the information herein is prohibited. -----BEGIN PGP SIGNATURE-----Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFAMlRraxdA/5C8vH8RAj2ZAKC4wgoI0YYhoXX5SKDKGvKvi9JLewCfd0Ll x0UHxedqC3n5Y13ZN1OG6Gc= =UPQQ -----END PGP SIGNATURE-----