Jump to content


Photo

Parse error?!?!


  • Please log in to reply
4 replies to this topic

#1 smarty_pockets

smarty_pockets
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 September 2006 - 09:24 PM

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


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


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 28 September 2006 - 09:46 PM

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

#3 smarty_pockets

smarty_pockets
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 September 2006 - 09:50 PM

I tried that too. I copied just this portion of code and made a new php file, and still got the error below:

Parse error: parse error, unexpected T_VARIABLE in /mnt/w0701/d01/s49/b0286312/www/redhutdesigns.com/Projects/TrackThisNote/test.php on line 5

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 28 September 2006 - 09:58 PM

It sounds like you may have an unprintable character in your code somewhere.  Try retyping the line where the error occurs.

Ken

#5 smarty_pockets

smarty_pockets
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 September 2006 - 10:24 PM

WOW!!! That worked!

Damn you copy paste!

Thanks a LOTT kenrbnsn! I really appreciate the help.  :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users