RE: [PHP-DB] PHP and MySql question

2005-04-18 Thread ReClMaples
Ok, I tried what you saidHere's the code:

$res = mysql_query(
"SELECT ZG_LATITUDE, ZG_LONGITUDE FROM zip_code where
zg_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("Error performing query: " .
 mysql_error() . "");
exit();
}


while ( $row = mysql_fetch_array($zipcode) )
{
echo("City: " . $row["ZG_CITY"]. "");
echo("State: " . $row["ZG_STATE"]. "");
echo("Zip Code: " . $row["ZG_ZIPCODE"]. "");
echo("Area Code: " . $row["ZG_AREACODE"]. "");
echo("County FIPS: " . $row["ZG_COUNTY_FIPS"]. "");
echo("County Name: " . $row["ZG_COUNTY_NAME"]. "");
echo("Time Zone: " . $row["ZG_TIME_ZONE"]. "");
echo("Day Light Savings?: " . $row["ZG_DST"]. "");
echo("Latitude: " . $row["ZG_LATITUDE"]. "");
echo("Longitude: " . $row["ZG_LONGITUDE"]. "");

}

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?

-Original Message-
From: Henrik Hornemann [mailto:[EMAIL PROTECTED]
Sent: Monday, April 18, 2005 2:44 AM
To: php-db@lists.php.net
Subject: SV: [PHP-DB] PHP and MySql question


Hi,

Your problem is that your variables $Lat1,$Lat2,$Lon1,$Lon2 all reffer
to resultsets and not the Latitudes or Longitudes.
Try something like this:

$res = mysql_query(
"SELECT ZG_LATITUDE, ZG-LONGITUDE FROM zip_code where
zg_zipcode = '$zip'");
List($Lat,$Lon) = mysql_fetch_row($res);
$Lat1=Lat-2; $Lat2=Lat+2; $Lon1=Lon-2; $Lon2=Lat+2;

Now you can use the values in your final query.

Hth Henrik Hornemann

-Oprindelig meddelelse-
Fra: ReClMaples [mailto:[EMAIL PROTECTED]
Sendt: 16. april 2005 22:38
Til: php-db@lists.php.net
Emne: [PHP-DB] PHP and MySql question

Hello, I'm kinda new at PHP programming with MySQL.  I am having an
issue and am not sure if this is the corret way to do this:  Here is my
code, I'll start there:

Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lat2 = mysql_query(
"SELECT (ZG_LATITUDE+2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lat2) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lon1 = mysql_query(
"SELECT (ZG_LONGITUDE-2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lon1) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lon2 = mysql_query(
"SELECT (ZG_LONGITUDE+2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lon2) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$ZipCode = mysql_query(
"SELECT * FROM zip_code where ZG_LATITUDE >= '$Lat1'
and ZG_LATITUDE <= '$Lat2' and ZG_LONGITUDE >= '$Lon1' and ZG_LONGITUDE
<= '$Lon2'");
  if (!$Zipcodesearch) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

  while ( $row = mysql_fetch_array($ZipCode) ) {
echo("City: " . $row["ZG_CITY"]. "");
echo("State: " . $row["ZG_STATE"]. ""); echo("Zip Code:
" . $row["ZG_ZIPCODE"]. ""); echo("Area Code: " .
$row["ZG_AREACODE"]. ""); echo("County FIPS: " .
$row["ZG_COUNTY_FIPS"]. ""); echo("County Name: " .
$row["ZG_COUNTY_NAME"]. ""); echo("Time Zone: " .
$row["ZG_TIME_ZONE"]. ""); echo("Day Light Savings?: " .
$row["ZG_DST"]. "");
echo("Latitude: " . $row["ZG_LATITUDE"]. "");
echo("Longitude: " . $row["ZG_LONGITUDE"]. ""); } ?>

Basically I'm trying to have a user input a zip code and then have a php
script pull all zip codes that are in a region of that submitted zip
code.
Can you have a look at my code and see what I'm doing wrong?  When using
this it returns no results but makes the connection to the database so I
have to believe that it's within here that I have my issue.

I have Apache/2.0.47 (Win32) PHP/4.3.9 Server and MySql 4.0.14 (I know I
can upgrade and be able to do subselects but I would like to know what
I'm doing wrong here.

Thanks in advance for any help.

Thanks
-rich

--
PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



SV: [PHP-DB] PHP and MySql question

2005-04-18 Thread Henrik Hornemann
Hi,

Your problem is that your variables $Lat1,$Lat2,$Lon1,$Lon2 all reffer
to resultsets and not the Latitudes or Longitudes.
Try something like this: 

$res = mysql_query(
"SELECT ZG_LATITUDE, ZG-LONGITUDE FROM zip_code where
zg_zipcode = '$zip'");
List($Lat,$Lon) = mysql_fetch_row($res);
$Lat1=Lat-2; $Lat2=Lat+2; $Lon1=Lon-2; $Lon2=Lat+2;

Now you can use the values in your final query. 

Hth Henrik Hornemann 

-Oprindelig meddelelse-
Fra: ReClMaples [mailto:[EMAIL PROTECTED] 
Sendt: 16. april 2005 22:38
Til: php-db@lists.php.net
Emne: [PHP-DB] PHP and MySql question

Hello, I'm kinda new at PHP programming with MySQL.  I am having an
issue and am not sure if this is the corret way to do this:  Here is my
code, I'll start there:

Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lat2 = mysql_query(
"SELECT (ZG_LATITUDE+2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lat2) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lon1 = mysql_query(
"SELECT (ZG_LONGITUDE-2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lon1) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lon2 = mysql_query(
"SELECT (ZG_LONGITUDE+2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lon2) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$ZipCode = mysql_query(
"SELECT * FROM zip_code where ZG_LATITUDE >= '$Lat1'
and ZG_LATITUDE <= '$Lat2' and ZG_LONGITUDE >= '$Lon1' and ZG_LONGITUDE
<= '$Lon2'");
  if (!$Zipcodesearch) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

  while ( $row = mysql_fetch_array($ZipCode) ) {
echo("City: " . $row["ZG_CITY"]. "");
echo("State: " . $row["ZG_STATE"]. ""); echo("Zip Code:
" . $row["ZG_ZIPCODE"]. ""); echo("Area Code: " .
$row["ZG_AREACODE"]. ""); echo("County FIPS: " .
$row["ZG_COUNTY_FIPS"]. ""); echo("County Name: " .
$row["ZG_COUNTY_NAME"]. ""); echo("Time Zone: " .
$row["ZG_TIME_ZONE"]. ""); echo("Day Light Savings?: " .
$row["ZG_DST"]. "");
echo("Latitude: " . $row["ZG_LATITUDE"]. "");
echo("Longitude: " . $row["ZG_LONGITUDE"]. ""); } ?>

Basically I'm trying to have a user input a zip code and then have a php
script pull all zip codes that are in a region of that submitted zip
code.
Can you have a look at my code and see what I'm doing wrong?  When using
this it returns no results but makes the connection to the database so I
have to believe that it's within here that I have my issue.

I have Apache/2.0.47 (Win32) PHP/4.3.9 Server and MySql 4.0.14 (I know I
can upgrade and be able to do subselects but I would like to know what
I'm doing wrong here.

Thanks in advance for any help.

Thanks
-rich

--
PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] PHP and MySql question

2005-04-16 Thread ReClMaples
Hello, I'm kinda new at PHP programming with MySQL.  I am having an issue
and am not sure if this is the corret way to do this:  Here is my code, I'll
start there:

Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lat2 = mysql_query(
"SELECT (ZG_LATITUDE+2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lat2) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lon1 = mysql_query(
"SELECT (ZG_LONGITUDE-2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lon1) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$Lon2 = mysql_query(
"SELECT (ZG_LONGITUDE+2) FROM zip_code where zg_zipcode =
'$zip'");
  if (!$Lon2) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

$ZipCode = mysql_query(
"SELECT * FROM zip_code where ZG_LATITUDE >= '$Lat1'
and ZG_LATITUDE <= '$Lat2' and ZG_LONGITUDE >= '$Lon1' and ZG_LONGITUDE <=
'$Lon2'");
  if (!$Zipcodesearch) {
echo("Error performing query: " .
 mysql_error() . "");
exit();
  }

  while ( $row = mysql_fetch_array($ZipCode) ) {
echo("City: " . $row["ZG_CITY"]. "");
echo("State: " . $row["ZG_STATE"]. "");
echo("Zip Code: " . $row["ZG_ZIPCODE"]. "");
echo("Area Code: " . $row["ZG_AREACODE"]. "");
echo("County FIPS: " . $row["ZG_COUNTY_FIPS"]. "");
echo("County Name: " . $row["ZG_COUNTY_NAME"]. "");
echo("Time Zone: " . $row["ZG_TIME_ZONE"]. "");
echo("Day Light Savings?: " . $row["ZG_DST"]. "");
echo("Latitude: " . $row["ZG_LATITUDE"]. "");
echo("Longitude: " . $row["ZG_LONGITUDE"]. "");
}
?>

Basically I'm trying to have a user input a zip code and then have a php
script pull all zip codes that are in a region of that submitted zip code.
Can you have a look at my code and see what I'm doing wrong?  When using
this it returns no results but makes the connection to the database so I
have to believe that it's within here that I have my issue.

I have Apache/2.0.47 (Win32) PHP/4.3.9 Server and MySql 4.0.14 (I know I can
upgrade and be able to do subselects but I would like to know what I'm doing
wrong here.

Thanks in advance for any help.

Thanks
-rich

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php