Jump to content

Parse error?!?!


smarty_pockets

Recommended Posts

I'm new to PHP (but not new to programming), so I'm pretty sure I'm missing something really trivial in the code below. When I try to run it, I get a parse error on the first line inside the function.
Any help would be hugely appreciated.

Thanks!!


[code]
function distancer($lat1,$lon1,$lat2,$lon2,$unit)
{
  $theta = $lon1 - $lon2;
  $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
  $dist = acos($dist);
  $dist = rad2deg($dist);
  $miles = $dist * 60 * 1.1515;
  switch (strtoupper($unit)) {
   case 'K':
$ret = $miles * 1.609344;
break;
case 'N':
$ret = $miles * 0.8684;
break;
default:
$ret = $miles;
  }
  return $ret;
}[/code]
Link to comment
Share on other sites

I copied you code to my machine. There are no errors in this piece of code. Is there code before this. Sometimes the PHP parser will get confused and it won't issue an error message when the error happens, but later in the code when it realizes that it's confused.

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.