RE: [PHP-DB] Unusual Array Results

2004-10-05 Thread Wendell Frohwein
Yup that was it, can't believe these people sale this software like
that. I should ask them to donate some money to everyone that helped me
on this for debugging purposes.

-Wendell Frohwein

-Original Message-
From: Andrew Kreps [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 05, 2004 5:49 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Unusual Array Results

On Tue, 5 Oct 2004 17:40:54 -0700, Wendell Frohwein
<[EMAIL PROTECTED]> wrote:
> Here is that inradius function:
> 

I think I see your problem.  The counter isn't initialized.  Try
sticking $i = 0 right here:

if($db->affected_rows()<>0) {
$i = 0;
   while($db->next_record()) {

and see if that works.  The variable $i appears to be undefined on the
first iteration of the while loop, which would explain why your first
array index is null.  Give it a shot, and let me know how it goes.

-- 
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



Re: [PHP-DB] Unusual Array Results

2004-10-05 Thread Andrew Kreps
On Tue, 5 Oct 2004 17:40:54 -0700, Wendell Frohwein
<[EMAIL PROTECTED]> wrote:
> Here is that inradius function:
> 

I think I see your problem.  The counter isn't initialized.  Try
sticking $i = 0 right here:

if($db->affected_rows()<>0) {
$i = 0;
   while($db->next_record()) {

and see if that works.  The variable $i appears to be undefined on the
first iteration of the while loop, which would explain why your first
array index is null.  Give it a shot, and let me know how it goes.

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



RE: [PHP-DB] Unusual Array Results

2004-10-05 Thread Wendell Frohwein
Here is that inradius function:

function inradius($zip,$radius)
{
global $db;
$query="SELECT * FROM zipcodes WHERE zipcode='$zip'";
$db->query($query);

if($db->affected_rows()<>0) {
$db->next_record();
$lat=$db->f("lat");
$lon=$db->f("lon");
$query="SELECT zipcode FROM zipcodes WHERE
(POW((69.1*(lon-\"$lon\")*cos($lat/57.3)),\"2\")+POW((69.1*(lat-\"$lat\"
)),\"2\"))<($radius*$radius) ";
$db->query($query);
if($db->affected_rows()<>0) {
while($db->next_record()) {



$zipArray[$i]=$db->f("zipcode");
$i++;
}
}
}else{
return "Zip Code not found";
}
 return $zipArray;
} // end func

I have also been trying to re-create my scenarios where the problem
first occurred using $anything[0], but have had no luck, it is either an
intermittent problem or I have not been getting enough sleep -=)

I yanked the code that gets the zips out of my main code and put it in a
file by itself to see how it reacts, same thing, you can see it here:

http://www.pdqval.com/admin/test.php

and the source here

http://www.pdqval.com/admin/test.sphp


Thanks again


-Wendell


-----Original Message-
From: Andrew Kreps [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 05, 2004 5:09 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Unusual Array Results

On Tue, 5 Oct 2004 16:50:04 -0700, Wendell Frohwein
<[EMAIL PROTECTED]> wrote:
> Hi Andrew. I'm using a class that was designed to search zip code
> radius's. Here is the piece that gets them.
> 
> 2 Mile Radius Search From 90606
> $radius="2";
> 
> $zipArray1 = $zipLoc->inradius("90606",$radius1);
> $zip_results1=count($zipArray1);
> 
> print_r($zipArray1);

Have you tried a print_r directly on the $zipLoc->inradius call?  Is
it a PHP library, and if so, can you look at what inradius is doing to
build that array?

-- 
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



Re: [PHP-DB] Unusual Array Results

2004-10-05 Thread Andrew Kreps
On Tue, 5 Oct 2004 16:50:04 -0700, Wendell Frohwein
<[EMAIL PROTECTED]> wrote:
> Hi Andrew. I'm using a class that was designed to search zip code
> radius's. Here is the piece that gets them.
> 
> 2 Mile Radius Search From 90606
> $radius="2";
> 
> $zipArray1 = $zipLoc->inradius("90606",$radius1);
> $zip_results1=count($zipArray1);
> 
> print_r($zipArray1);

Have you tried a print_r directly on the $zipLoc->inradius call?  Is
it a PHP library, and if so, can you look at what inradius is doing to
build that array?

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



RE: [PHP-DB] Unusual Array Results

2004-10-05 Thread Wendell Frohwein
Hi Andrew. I'm using a class that was designed to search zip code
radius's. Here is the piece that gets them.

2 Mile Radius Search From 90606
$radius="2";

$zipArray1 = $zipLoc->inradius("90606",$radius1);
$zip_results1=count($zipArray1);

print_r($zipArray1);

I'm starting to think it's not php. Just because I tried this code:

$string="Wendell Frohwein";
$split=explode(" ",$string);

$fname=$split[0];
$lname=$split[1];

print_r($split);

And the result that came back was:

Array ( [0] => Wendell [1] => Frohwein )

I bought the zip code software from

http://www.newdataweb.com/software/zipcode/index.php

So, maybe it's something with there software that creates the array,
Sorry if I wasted anyone's time -=/


-Wendell Frohwein



-Original Message-
From: Andrew Kreps [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 05, 2004 3:43 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Unusual Array Results

On Tue, 5 Oct 2004 13:49:11 -0700, Wendell Frohwein
<[EMAIL PROTECTED]> wrote:
> Hello all again, I am using php 5.0.1 with mysql 4.1.4a-gamma. After I
> did this upgrade, I noticed pieced of my code were failing. Took me a
> while to figure it out. When I would be working with arrays, sometimes
I
> would call the values out like so:
> 
> $value=$thearray[0];
> 
> Every piece of script where I refer to the value like this has failed.
> So I ran a print_r() function to see what the output is. This is what
I
> got:
> 
> Array ( [] => 90606 [1] => 90610 [2] => 90660 [3] => 90661 [4] =>
90662
> [5] => 90665 )
> 
> This is not a huge problem, I just have to use foreach() instead of
> for() in my loop. Took me a good while to figure this out.
> Could this be a glitch within php 5.0.1? If so, where could I report
> this?
> 

How are you populating your array?  I just tried your code creating
the array as such:

$arr = array (90606, 90610, 90660, 90661, 90662);

and I got the desired result, which is a 0 indexed array.  I'm running
PHP 5.0.1 as well, so I don't think this is a bug with the
interpreter.  Can you post your array initialization code?

-- 
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



Re: [PHP-DB] Unusual Array Results

2004-10-05 Thread Andrew Kreps
On Tue, 5 Oct 2004 13:49:11 -0700, Wendell Frohwein
<[EMAIL PROTECTED]> wrote:
> Hello all again, I am using php 5.0.1 with mysql 4.1.4a-gamma. After I
> did this upgrade, I noticed pieced of my code were failing. Took me a
> while to figure it out. When I would be working with arrays, sometimes I
> would call the values out like so:
> 
> $value=$thearray[0];
> 
> Every piece of script where I refer to the value like this has failed.
> So I ran a print_r() function to see what the output is. This is what I
> got:
> 
> Array ( [] => 90606 [1] => 90610 [2] => 90660 [3] => 90661 [4] => 90662
> [5] => 90665 )
> 
> This is not a huge problem, I just have to use foreach() instead of
> for() in my loop. Took me a good while to figure this out.
> Could this be a glitch within php 5.0.1? If so, where could I report
> this?
> 

How are you populating your array?  I just tried your code creating
the array as such:

$arr = array (90606, 90610, 90660, 90661, 90662);

and I got the desired result, which is a 0 indexed array.  I'm running
PHP 5.0.1 as well, so I don't think this is a bug with the
interpreter.  Can you post your array initialization code?

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