FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » From city to lati and long
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: From city to lati and long [message #175033 is a reply to message #175032] Thu, 04 August 2011 23:21 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Thu, 04 Aug 2011 15:22:20 -0400, Jerry Stuckle wrote:

> Sure, I reject them - because I believe in finding the PROBLEM - not
> guess and try things until something might work *right now*. She can
> do that - she can jump up and down on the sofa, or hold her breath until
> she's blue in the face. All have an equal likelihood of finding the
> problem.

So you reject the suggestions I make to try and find the problem because
you believe the correct solution is to find the problem.

The "problem" might be:

(a) she is making a malformed request (that she will need to refer to
google)
(b) she is sometimes getting valid data in different format to that which
she expects (the logging I suggest will help identify that problem)
(c) she is occasionally getting something other than a 200 response from
the google maps server but she is not recognising let alone handling that
response (the logging I suggest will help identify that problem, and
using curl instead of file to get the page will provide a better
mechanism to handle such cases)

Now I will agree that from her description of the problem I have no idea
what is causing these errors. Clearly nor does she, and clearly nor do
you. That's a given.

However, I believe that there are constructive steps that can be taken
using php to identify several possible issues that might be arising and
in some cases mitigate or resolve those issues.

I'm pretty sure that, for example, opening a url with "file()" won't pay
any attention to response codes, so the content of the array that you
assign the return of the function call to (given that the return value
was not false, something she doesn't test for) could be an error page,
some sort of redirection, etc.

But she's using file and assuming that she always gets csv data whose
first line is in a standard format.

The first rule of getting data from an external source is surely to
sanitise, verify and validate?

Which is why I also think she should check that what she gets is what she
expects before she starts doing things like exploding it. And if she has
a csv string, there may be better ways to process that too.

eg if she thinks expects a 4 value csv string:

<?php
$arr = str_getcsv ($the_string_of_csv_data);
$items = count($arr);
if ($items !== 4)
{
alert_mission_control("Houston, we have a problem! Found {$items}
elements in the csv data, expected 4 elements. position was
'{$position}', location[0] was '{$location[0]}'")
}
?>

might be a better approach than her:

<?php
list ($a, $b, $c, $d) = explode (",", $the_string_of_csv_data);
?>

Rgds

Denis McMahon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: What is Islam?
Next Topic: Using function prototypes in code
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 02:04:43 GMT 2024

Total time taken to generate the page: 0.04029 seconds