boeing747fp
03-27-2010, 05:39 AM
i have the following line of php (query with variables in it) and it keeps failing saying
"unknown column 'distance' in 'where clause'"
the query works without the where clause at all, but it returns all rows and just sorts by distance... i want to be able to filter it by number of miles
$sql=mysql_query("SELECT *,3956*2*ASIN(SQRT(POWER(SIN((".$mylat." -
abs(lat))*pi()/180/2),2)+COS(".$mylat."*pi()/180)*COS(abs(lat)*pi()/180)*POWER
(SIN((".$mylon."-lon)*pi()/180/2),2))) as `distance` FROM `listings` WHERE
`distance` <= ".$_REQUEST['miles']." ORDER BY `distance` ASC");
any ideas?
"unknown column 'distance' in 'where clause'"
the query works without the where clause at all, but it returns all rows and just sorts by distance... i want to be able to filter it by number of miles
$sql=mysql_query("SELECT *,3956*2*ASIN(SQRT(POWER(SIN((".$mylat." -
abs(lat))*pi()/180/2),2)+COS(".$mylat."*pi()/180)*COS(abs(lat)*pi()/180)*POWER
(SIN((".$mylon."-lon)*pi()/180/2),2))) as `distance` FROM `listings` WHERE
`distance` <= ".$_REQUEST['miles']." ORDER BY `distance` ASC");
any ideas?