Hello I'm recieving this error on my user profiles:

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 'DISTINCT(n.nid), n.changed FROM node n WHERE n.uid = 1 AND n.type = 'release' AN' at line 1 query: SELECT n.created, n.title, DISTINCT(n.nid), n.changed FROM node n WHERE n.uid = 1 AND n.type = 'release' AND n.status = 1 ORDER BY n.changed DESC LIMIT 0, 5 in /home/xxx/xxx.com/sites/all/themes/xxx/user-profile.tpl.php on line 78.

It's referring to this:

<?php
$nlimit = 5;
$query= "SELECT n.created, n.title, n.nid, n.changed FROM {node} n WHERE n.uid = %d AND n.type = 'release' AND n.status = 1 ORDER BY n.changed DESC";
$result = db_query_range(db_rewrite_sql($query), $account->uid, 0, $nlimit);
$output5 .= "<div class=\"item-list\"><ul>\n";
$output5 .= node_title_list($result);
$output5 .= "</ul></div>";
print $output5; ?>

Which works perfectly prior to enabling. I am running the latest Drupal version, 6.14.

Of course, when I remove "n.nid", it stops.... but is this suppose to happen? It was working fine as such.

Any help?

Comments

salvis’s picture

Category: bug » support

Is this new with Drupal 6.14? Or did you see it with Drupal 6.13 already?

I'm not sure what is happening here, but there should be more changes from db_rewrite_sql().

Try putting n.nid first.

Try removing FA and ACL and installing Content Access instead. I'm pretty sure you'll get the same behavior...

00110000’s picture

It happens in both 6.13 (my test site) and 6.14 (my actual in production site).

Will try what you suggested in a moment.

00110000’s picture

It worked! On my test site. THANK YOU VERY MUCH. :D

It more than likely will be fine on 6.14, if not I'll probably mention here.

Greatly appreciated!

salvis’s picture

It worked! On my test site.

What is it that worked? Putting n.nid first?

The code you posted is custom code of your own (sites/all/themes/xxx/user-profile.tpl.php), right? Or is it from a core or contrib theme?

00110000’s picture

Putting the n.nid first e.g. SELECT n.nid, n.created, n.title etc.

It's a custom code placed within the user-profile.tpl.php.

The theme is a very heavily modified Garland theme, which looks nothing like it at this point.

This worked fine on 6.14 as well. So all is good, thanks again!

salvis’s picture

Status: Active » Fixed

Great, thanks for letting us know!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.