Re: zip code locator problems
| From: | Ignacio Vazquez-Abrams | Date: | Fri, 01 Dec 2000 19:09:41 +0000 |
| Subject: | Re: zip code locator problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28259@lists.php.net to get a copy of this message | ||
On Tue, 28 Nov 2000, Tom Beidler wrote:
> I have a dealer locator that attempts to find dealers thru a range of zip
> codes. The end user enters a zip, two variables are created $high=$zip+10
> and $low=zip-10 and then runs the following query on a MySQL database;
>
> $query = "SELECT name, bill_address1, bill_address2, bill_city, bill_state,
> bill_zip, phone, email from dealer WHERE bill_country = 'USA' AND (zip <=
> '$high' AND bill_zip > '$low') ORDER BY name";
> $result = mysql_query ($query)
> or die ("Cannot execute query");
>
> Everything works fine except for zips with a 0 preceeding, ie 01095 finds
> 10951 and 11021.
>
> Obvious issues include the zip column in the MySQL database is a varchar and
> not an int. I did that to accomidate for hyphenated zip codes, ie.
> 44012-0987.
>
> I can I fix this?
>
> Any help is greatly appreciated,
> Tom
>
> >>.>>.>>>.>>>>>.>>>>>>>>>
> Tom Beidler
> Orbit Tech Services
> 805.455.7119 (cell)
> 805.682.8972 (phone)
> 805.682.5833 (fax)
> tbeidler@mindspring.com
> >>.>>.>>>.>>>>>.>>>>>>>>>
>
Just taking a quick look over your code, if the problem isn't that $high and
$low are numeric, then it's because you're missing quotes around them in the
query.
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>