When calling Visitors Location Map with admin/reports/visitorinfo I am getting a red error message like that one ....

"user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (n.language ='en' OR n.language ='' OR n.language IS NULL) LIMIT 0, 200' at line 1 query: SELECT * FROM visitorinfo order by csid desc WHERE (n.language ='en' OR n.language ='' OR n.language IS NULL) LIMIT 0, 200 in /home/jadajadajada/public_html/blablabla/sites/all/modules/visitorinfo/visitorinfo.module on line 75."

with the Visitors Location Map just underneath that read error message, but the map does not show a single visitor location .... and never changes this "Last 1 visitor locations." note just above the global map.

visitors are arriving at the site so that is not the problem ...

Comments

twooten’s picture

Assigned: Unassigned » twooten
Status: Active » Needs review
StatusFileSize
new776 bytes

I believe that is due to my use (mis-use is probably more accurate), of the db_rewrite_sql() function. From what I have been able to determine, it is supposed to be used in circumstances such as when you are doing a node listing, when other conditions need to be tested as well. For instance, the node module modifies queries for node listings to filter nodes protected by access fields. So basically what that means is that you would use db_rewrite_sql() if you were producing a listing of nodes but some of those nodes should only be shown to certain users. db_rewrite_sql()'s usage would ensure that those access rules were observed.

I believe the particular error above is due to calling db_rewrite_sql() with the wrong number of arguments. Those arguments are apparently needed when certain other modules are actually performing a rewrite of the sql. But as I think about it, I realize that I do not need to use that function, a simple db_query_range() would work just fine. The documentation for the database abstraction layer says regarding db_rewrite_sql() 'Use it for listing queries'. That's not what I am doing. db_query_range() is better suited since it 'runs a limited-range query in the active database'.

I was able to recreate an error very similar on another site. Applying this patch seemed to clear up the problem.

bavarian’s picture

is it just me post-christmas-drunk to experience this patch as weird, as a link to drupal-main-site ?

or is there a textfile behind this patch-link or not ?

thanks for your attempt anyway ....

twooten’s picture

StatusFileSize
new571 bytes

Awesome... I uploaded a .patch file. Let's try again with a .zip

Ok, nope that didn't work either. Something I should know about uploading files here?

Tim

bavarian’s picture

Weird ... but there is no rush !

twooten’s picture

StatusFileSize
new571 bytes
twooten’s picture

there we go. It was the '#' in the name. I should have known.

bavarian’s picture

will check file later on ... managed to d-load it now !

thank you !

bavarian’s picture

oh ... it made a biiiiiig difference. on a first glance your patch did the trick and things seem to work the way they are supposed to work !

thank you !

dave reid’s picture

I think actually you just need to use capital letters with your SQL commands (order by csid desc vs ORDER BY csid DESC). But yes, you should not be using db_rewrite_sql() unless you know that it's a query that should be using it (like on nodes, taxonomy terms, etc).

twooten’s picture

Status: Needs review » Fixed
twooten’s picture

Status: Fixed » Closed (fixed)