I have the following code...
<?php
session_start();
require_once('myDB.php');
if (isset($_POST))
{
foreach($GLOBALS['myDB']->getShops()as $i)
{
$tempLat = $i['latitude'];
$templong = $i['longitude'];
$distance = distance($_POST['latitude'],$_POST['longitude'],$tempLat,$templong);
if($distance <= 300)
{
echo "".$i['id']."|".$i['shopName']."|".$i['longitude']."|".$i['latitude']."|".$i['advert']."|";
}
}
}
function distance($lat1, $lon1, $lat2, $lon2) {
$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;
return (($miles * 1.609344)*1000);
}
?>
Now when I get to see that page it gives me Error 324 (net::ERR_EMPTY_RESPONSE) and it says that the website may be temporarily down...If i try to open the page using firefox it opens a dialog for downloading the php file...
What I would like to do is to have it print either the echoes (if distance is in fact bigger than 300 meters) or nothing at all but it should still be an empty html page...
Can anyone see whats wrong with that???
NOTE: The code works fine locally but not on my server..however every other page works as expected so the server is up and running...
Ok after commenting out and uncommenting each line one by one I found where the problem is...
foreach($GLOBALS['myDB']->getShops()as $i)
The query in the database was failing because of the type of a field set to longtext...
Makes no sense at all but changing that to varchar fixed the problem...