Re: PHP and Mysql help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,

That is a lot of code, so I only skimmed it, but right off the bat i noticed that you are missing a space in between WHERE and zg_zipcode, as shown below:

$res = mysql_query("SELECT ZG_LATITUDE, ZG_LONGITUDE FROM zip_code
wherezg_zipcode = '$zip'");

should be:

$res = mysql_query("SELECT ZG_LATITUDE, ZG_LONGITUDE FROM zip_code
WHERE zg_zipcode = '$zip'");

I hope this helps...

- Colin Busby

---
Colin Busby
Sackville, NB Canada
http://www.colinbusby.ca

On 24-Apr-05, at 7:54 PM, ReClMaples wrote:

Can someone help me out with an issue I'm having?



Here is my code:

$res = mysql_query("SELECT ZG_LATITUDE, ZG_LONGITUDE FROM zip_code
wherezg_zipcode = '$zip'");

List($Lat,$Lon) = mysql_fetch_row($res);

$Lat1 = ($Lat-2);

$Lat2= ($Lat+2);

$Lon1= ($Lon-2);

$Lon2= ($Lon+2);

//echo ($Lat1);

//echo ($Lat2);

//echo ($Lon1);

//echo ($Lon2);

$zipcode = mysql_query(

"SELECT * FROM zip_code where ZG_LATITUDE >= $Lat1

and ZG_LATITUDE <= $Lat2 and ZG_LONGITUDE >= $Lon1 and ZG_LONGITUDE <=

$Lon2");

if (!$zipcode) {

echo("<P>Error performing query: " .

mysql_error() . "</P>");

exit();

}



while ( $row = mysql_fetch_array($zipcode) )

{

echo("<b>City: </b>" . $row["ZG_CITY"]. "<br>");

echo("<b>State: </b>" . $row["ZG_STATE"]. "<br>");

echo("<b>Zip Code: </b>" . $row["ZG_ZIPCODE"]. "<br>");

echo("<b>Area Code: </b>" . $row["ZG_AREACODE"]. "<br>");

echo("<b>County FIPS: </b>" . $row["ZG_COUNTY_FIPS"]. "<br>");

echo("<b>County Name: </b>" . $row["ZG_COUNTY_NAME"]. "<br>");

echo("<b>Time Zone: </b>" . $row["ZG_TIME_ZONE"]. "<br>");

echo("<b>Day Light Savings?: </b>" . $row["ZG_DST"]. "<br>");

echo("<b>Latitude: </b>" . $row["ZG_LATITUDE"]. "<br>");

echo("<b>Longitude: </b>" . $row["ZG_LONGITUDE"]. "<P>");

}

I get no results with this still, it acutally doesn't even go to the this

page. When I uncomment out:

//echo ($Lat1);

//echo ($Lat2);

//echo ($Lon1);

//echo ($Lon2);

and comment out everything below this, I get the expected results for

$Lat1,$Lat2,$Lon1, and $Lon2. So I have to believe my issue is below those

lines, can anyone see what I have that is incorrect here?




[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux