I try to save the query values into an array, but it wont become filled. The query should give something out because any values in the database accomplish the terms and the cookies have too a value. Where is my mistake?
Output:
Array ( )
$range = 'range';
$_COOKIE["$range"];
$longitude = 'longitude';
$_COOKIE["$longitude"];
$latitude = 'latitude';
$_COOKIE["$latitude"];
$onemile = 0.005581257;
$le = $range * $onemile;
$lo = $longitude + $le;
$loo = $longitude - $le;
$la = $latitude + $le;
$laa = $latitude - $le;
$hostname='localhost';
$user='root';
$password='';
try {
$dbh = new PDO("mysql:host=$hostname;dbname=loc",$user,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
$sql = "SELECT id, autorid, date, longitude, latitude, title, text
FROM post
WHERE (
longitude >= $loo and longitude <= $lo
)
OR (
latitude >= $laa and latitude <= $la
)
ORDER BY date";
if ($res = $dbh->query($sql)) {
$result = $res->fetchAll();
print_r($result);
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}