frustration is setting in
Posted: Thu Dec 16, 2004 10:15 am
I've been working and re-working this for hours and getting nowhere fast. Here's a snippet of code I'm trying to get to work.
I have a table "zones" with one zone for each city,state combination. If I echo $query, I get the following:
SELECT zone FROM zones WHERE city = 'Aurora' and state = 'IL'
If I run that query directly from the database, the resulting zone is 5. However, from the program, the resulting zone is 99. It's always 99. I've tried several approaches including putting the result into an array, but I always get 99 instead of the actual zone.
Would someone point me in the right direction? I know it's me, but I cannot figure out why it doesn't work.
Code: Select all
$query = "SELECT zone FROM zones WHERE city = '$city' and state = '$st'";
$result = mysql_query( $query );
$rows = mysql_num_rows($result);
if ($rows == 0) {
$zone = 99;
}
else {
$zone = $result;
}SELECT zone FROM zones WHERE city = 'Aurora' and state = 'IL'
If I run that query directly from the database, the resulting zone is 5. However, from the program, the resulting zone is 99. It's always 99. I've tried several approaches including putting the result into an array, but I always get 99 instead of the actual zone.
Would someone point me in the right direction? I know it's me, but I cannot figure out why it doesn't work.