Parse error: syntax error, unexpected T_AS in C:\wamp\www\Adreach\application\models\offerModel.php on line 13 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Parse error: syntax error, unexpected T_AS in C:\wamp\www\Adreach\application\models\offerModel.php on line 13 (/showthread.php?tid=49779) |
Parse error: syntax error, unexpected T_AS in C:\wamp\www\Adreach\application\models\offerModel.php on line 13 - El Forum - 03-03-2012 [eluser]bsrbvr[/eluser] Hi, I am getting above parse error on line 13 when executing this query. Is any other way to perform mathematical operations in codeigniter? Code: public function get_nearestOffers($slug1,$slug2) Thanks Parse error: syntax error, unexpected T_AS in C:\wamp\www\Adreach\application\models\offerModel.php on line 13 - El Forum - 03-03-2012 [eluser]PhilTem[/eluser] You've forgotten to but AS distance within a string. Use Code: $this->db->select('loc.location_id, ' . ( 3959 * acos( cos( radians($data['area_latitude']) ) *cos( radians( loc.location_lat ) ) * cos( radians( loc.location_long ) - radians($data['area_longitude']) ) +sin( radians($data['area_latitude']) ) * sin( radians( loc.location_lat ) )) ) . " AS `distance`"); Might be that I screwed up with some brackets, but basically $this->db->select() only accepts one parameter which must be the fields you want to select (or any other thing that usually is used with MySQL's SELECT-statement). The second parameter for db->select(), howerver, is to prevent the string to be escaped. http://ellislab.com/codeigniter/user-guide/database/active_record.html Part $this->db->select(); Parse error: syntax error, unexpected T_AS in C:\wamp\www\Adreach\application\models\offerModel.php on line 13 - El Forum - 03-03-2012 [eluser]bsrbvr[/eluser] Thanks for reply. I changed like You said. Now I am getting the following. Fatal error: Call to undefined function radians() |