Q:

MySQL error...#1305

I've had below error occurred when I queried this through my controller in Cakephp for MySQL query.
SELECT id, 6371 * ACos(COS(RADIANS(users.latitude)) * Cos
                        (RADIANS(35)) * Cos(RADIANS(33) - RADIANS
                        (users.longitude)) + Sin(RADIANS(users.latitude)) * Sin
                        (RADIANS(35)) ) AS distance
                        FROM users
                        ORDER BY distance
                        LIMIT 20;

I'm stuck here...Do anyone know what this problem is?
Warning (512): SQL Error: 1305: FUNCTION wmetools_track.Cos does not exist [APP/cake/libs/model/datasources/dbo_source.php, line 684]
Code | Context

DboSource::showQuery() - APP/cake/libs/model/datasources/dbo_source.php, line 684
DboSource::execute() - APP/cake/libs/model/datasources/dbo_source.php, line 266
DboSource::fetchAll() - APP/cake/libs/model/datasources/dbo_source.php, line 410
DboSource::query() - APP/cake/libs/model/datasources/dbo_source.php, line 287
Model::query() - APP/cake/libs/model/model.php, line 2463
UsersController::api_localusers() - APP/controllers/users_controller.php, line 88
Dispatcher::_invoke() - APP/cake/dispatcher.php, line 204
Dispatcher::dispatch() - APP/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83

A:

It looks like MySQL doesn't like the whitespace between the function name and the opening parenthesis. 
select cos    (0.4) -- error
select cos(0.4) -- works

edit:
The MySQL Documentation supports this. But apparently there's a Workaround: using the "IGNORE_SPACE" should solve your problem (a part from just removing the whitespace between the function name and the opening parenthesis). 

