hi all , I have this SQL Query :
Code:
SELECT *, ( 3959 * acos( cos( radians(41.832100) ) * cos( radians( latitude ) ) * cos( radians( longitude) - radians(-87.789597) ) + sin( radians(41.832100) ) * sin( radians( latitude ) ) ) ) AS distance FROM cities_extended HAVING distance < 10 ORDER BY distance LIMIT 0 , 5;
when I run it through phpMyAdmin or n the command line it works.
However I tried to implement it with codeigniter via the
$this->db->query(); function.
like so :
Code:
$nearby_cities = $this->db->query("SELECT city,state,zip, ( 3959 * acos( cos( radians($latitude) ) * cos( radians( latitude ) ) * cos( radians( longitude) - radians($longitude) ) + sin( radians($latitude) ) * sin( radians( latitude ) ) ) ) AS distance FROM cities_extended HAVING distance < 25 ORDER BY distance LIMIT 0 , 3;");
and I get this :
Code:
Error Number: 1582
Incorrect parameter count in the call to native function 'radians'
SELECT city,state,zip, ( 3959 * acos( cos( radians() ) * cos( radians( latitude ) ) * cos( radians( longitude) - radians() ) + sin( radians() ) * sin( radians( latitude ) ) ) ) AS distance FROM cities_extended HAVING distance < 25 ORDER BY distance LIMIT 0 , 3;
it does not make sense that when I run the exact same query on phpmyadmin and through the command line on mysql it works , but with php and codeigniter, mysql gives me an error. can any one help ?