Re: zip code locator problems

From: Date: Fri, 01 Dec 2000 19:14:09 +0000
Subject: Re: zip code locator problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-28263@lists.php.net to get a copy of this message
On Fri, 1 Dec 2000, Ignacio Vazquez-Abrams wrote: > 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. > Never mind, I see the quotes now. My bad :) Check the numeric possibility regardless. -- Ignacio Vazquez-Abrams <ignacio@openservices.net>

« previous php.general (#28263) next »