I get a string from java: “2011-11-25 08:16:50”
post_date column is TIMESTAMP
But the following query gives no results. What is the error?
$date2 = $_POST['Date'];
$result= mysql_query("Select * FROM (Select * FROM user WHERE latitude > $minLat AND latitude < $maxLat AND longitude > $minLon AND longitude < $maxLon AND post_date > $date2 ORDER BY post_date DESC LIMIT $amount1) a ORDER BY post_id");
while($results = mysql_fetch_assoc($result))
$output[]=$results;
print(json_encode($output));
mysql_close();
You must single-quote dates in MySQL. Additionally, since you are acquiring it directly from
$_POST, you are advised to escape it withmysql_real_escape_string()first.