Re: '&' Sign in _GET Parameter
| From: | CPT John W. Holmes | Date: | Fri, 22 Aug 2003 19:23:11 +0000 |
| Subject: | Re: '&' Sign in _GET Parameter | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-160443@lists.php.net to get a copy of this message | ||
From: "Pushpinder Singh Garcha" <pgarcha@adelphia.net>
> I am using an application where I retrieve user profile from a MySQL
> DB using the Company Name . I pass the name of the company to the PHP
> script as a '$_GET' parameter. e.g. when the name of the company is
> 'IBM'. , the URL with the query string would look like :
> http://masterstream.com/CRM/full_profile_1.php?name=IBM
>
> Now one of the records had a name : PSG & Inc. , in this case the URL
> with the query string would look like
>
> http://masterstream.com/CRM/full_profile_1.php?name=PSG%20&%20Inc.
>
> However in the case of the latter I am not able to pull out any records
> from the MySQL database. It says that "no records with the name were
> found". I went ahead and tweaked the name of the company, to remove
> the "&" sign in 'PSG & Inc.' Now the query works fine. Can some
> one
> throw some light here. I am sure something minor is to be done when
> passing the name of the company in the parent script.
The & character separates variables in the query string, so it must be
encoded if it appears in the data. Take a look at
http://us2.php.net/urlencode
---John Holmes...