Welcome Guest, Not a member yet? Register   Sign In
Incorrect parameter count in the call to native function 'radians'
#1

(This post was last modified: 01-24-2018, 10:56 AM by ciadmin. Edit Reason: SEO link redacted )

Hi

When submitting a postcode, say TW1 3HG, [SEO link redacted], it will either show a correct result or this error:

Error Number: 1582
Incorrect parameter count in the call to native function 'radians'

SELECT *, ( 3959 * acos( cos( radians() ) * cos( radians( `latitude` ) ) * cos( radians( `longitude` ) - radians() ) + sin( radians() ) * sin( radians( `latitude` ) ) ) ) AS `distance` FROM `dentist` HAVING `distance` < 10 AND dentist.is_active = 1 AND dentist.non_uk = '0' ORDER BY `distance`
Filename: /home/blos/public_html/models/dentist_model.php
Line Number: 81

It is intermittent. If you refresh the page a few times the correct page shows. If you refresh again more than likely the error will return. Maddening!

The site uses CodeIgniter version 2.2.0

Any ideas?

Thanks for reading
John
Reply
#2

@johnbow,

Many questions...
Why haven't you upgraded to 2.2.6?
What method/function calls this statment?
How many parameters does the method/function expect?
Maybe you should kickout the generated SQL statement so that you can see exactly what is being sent to the database.
My guest is that a parameter disappears during the refreshing of the page which causes the sql statement to fail.
Do you verify that you have the necessary parameters for the query to execute properly.
What fail proof features do you have in the method/function call of the sql statement?
Reply
#3

(01-24-2018, 11:40 AM)php_rocs Wrote: Why haven't you upgraded to 2.2.6?

2.2.6 is not ok.
2.x is not ok.
Anything but 3.1.latest is not ok.
Reply
#4

Ignoring the CI version issue for the moment, I see multiple calls to radians that do not provide an argument and, AFAIK, an argument is required. That it ever works is more of mystery than the sporadic failures.
Reply
#5

(This post was last modified: 01-24-2018, 01:15 PM by php_rocs.)

@Narf, I agree but I figured that if you are going to be running an old version at least have the last old version. Also, I'm guessing that maybe he is working on an old system so upgrading may not be in the immediated future (hopefully the forseable future).
Reply
#6

(This post was last modified: 01-24-2018, 03:30 PM by ciadmin. Edit Reason: SEO link removed )

Hi all
Thank you for your speedy responses.
I'm not really familiar with CodeIgniter, having inherited the site. So please bear with me.
The search form here http://EXAMPLE.COM/find-an-orthodontist sends the correct parameter ('zipcode') but it doesn't always register as an argument for 'radians' in the SQL.
What's really weird (and frustrating) is that it works sporadically.
Could this be to do with CI's query cache?
Thanks
John
Reply
#7

As @Narf said you should update to the newest version of CodeIgniter for Security Reasons.

Read This:

MySQL: Calculating Distance Based on Latitude and Longitude
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

(01-24-2018, 01:14 PM)php_rocs Wrote: @Narf, I agree but I figured that if you are going to be running an old version at least have the last old version.

That doesn't make any difference, especially 2+ years after EOL. Even if they listen, so what? They'll just falsely think it's all ok now ...

(01-24-2018, 01:14 PM)php_rocs Wrote: Also, I'm guessing that maybe he is working on an old system so upgrading may not be in the immediated future (hopefully the forseable future).

Maintaining up-to-date dependencies is a responsiblity. Too many people will look for excuses to avoid it, and you likely won't be able to push many of them in the right direction, but if you're going to say anything about that, at least don't be complicit.
Reply
#9

@Narf,

I agree with you but every developer may not be in a position where they can come in and make drastic changes (unlike you and me =) ). Sometimes it has to be baby steps. I'm quite sure both of us has many stories we could tell where it was so obvious that an upgrade was needed but management was being a pain and didn't fully understand the impact (I even worked on a project where I was more experienced then the Team lead and had to indirectly lead the team and upgrade the code). In those scenarios you have to do what you can until you can get to the point where the software can be made current. That is why sometimes it worth saying hey do this at least until you can do that.
Reply
#10

(01-30-2018, 11:29 AM)php_rocs Wrote: @Narf,

I agree with you but every developer may not be in a position where they can come in and make drastic changes (unlike you and me =) ).  Sometimes it has to be baby steps. I'm quite sure both of us has many stories we could tell where it was so obvious that an upgrade was needed but management was being a pain and didn't fully understand the impact (I even worked on a project where I was more experienced then the Team lead and had to indirectly lead the team and upgrade the code).  In those scenarios you have to do what you can until you can get to the point where the software can be made current.  That is why sometimes it worth saying hey do this at least until you can do that.

It's an update, not a rewrite - there's nothing drastic about it and management shouldn't even be asked about this. The only reason management becomes a PITA with this is because when you ask them how to do your own job, they assume it's a big deal with meaningful impact on business operations (oh have I got many stories about that, indeed).

Let me tell you about the last time I updated CI for a company ... Granted, knowing CI inside out, this should be like a walk in the park for me, but even if you double the time it takes, it's no big deal for anybody.

They were running 2.0.something, with a bulk of custom patches on top of it (some of those, they claimed was for specific stuff that CI couldn't do, which was false - they had shot themselves in their collective foot for nothing). That wasn't one small-to-medium size project, but 3 separate ones, each having at least 100 controllers. Copy-pasta all over the place. And I don't use IDEs, so I couldn't do my colleagues favorite "global search and replace" - every single change, done by hand, not even auto-complete.

I spent 2 days extracting those custom patches into extensions, and completely reverting the parts that were no longer necessary, then the upgrade itself took 3 hours.

Seriosly, it takes more time to QA than to actually do it. There's no excuses.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB