After installing this module and enabling the block with all defaults, I am receiving the following errors:

* 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 ') ORDER BY RAND()' at line 5 query: SELECT `nid` FROM node WHERE `status` = 1 AND `type` IN ('product') AND NOT nid IN () ORDER BY RAND() in /var/www/html/drupal-6/drupal/sites/all/modules/ubercart/contrib/uc_upsell/uc_upsell_core.inc on line 215.
* 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 ') ORDER BY RAND()' at line 5 query: SELECT `nid` FROM node WHERE `status` = 1 AND `type` IN ('product') AND NOT nid IN () ORDER BY RAND() in /var/www/html/drupal-6/drupal/sites/all/modules/ubercart/contrib/uc_upsell/uc_upsell_core.inc on line 215.

Cheers,

Antoine

CommentFileSizeAuthor
#10 uc_upsell_687032-dev.patch836 bytespcambra

Comments

jantoine’s picture

Version: 6.x-1.21 » 6.x-1.x-dev

This is also present in the latest dev snapshot.

Cheers,

Antoine

jantoine’s picture

I should note that these errors appear when visiting a product page that the block is displayed on. I would also like to mention that when associating items via the "product associations browser", the error goes away and the block appears for those products that were given associations.

Cheers,

Antoine

torgospizza’s picture

So it's missing the "NOT nid in" part of the query, which is the array of nodes it's supposed to Filter. In other words these are usually nodes that are in the cart while on the cart page. I'll look into a fix and a patch.

torgospizza’s picture

Yeah, try this. At line 208, change this line:

$filter_query = implode(",", array_merge($ary, uc_upsell_get_cart_nids()));

to this:

$filter_query = implode(",", array_merge($ary, uc_upsell_get_cart_nids(), array((isset($nid)) ? $nid : 0)));

And see if that fixes it. This way at the very least you'll get a nid of 0, which never exists, but at least it gives a failover scenario in case there's nothing to filter. This is what it originally looked like, can't remember the exact reason why I changed it. Something to do with $product_nid... so this is untested but I don't know of any side effects offhand.

mrvoo’s picture

thanks for your line - it works for me.

jantoine’s picture

Status: Active » Fixed

The fix in #4 fixes the issue, thus I am marking it as fixed. Thanks for the quick reply!

Cheers,

Antoine

Status: Fixed » Closed (fixed)

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

dreadfulcode’s picture

#4 Works.

Same error message, applied the code, bye bye error.

Thanks

ahimsauzi’s picture

Same here code fixed the issue. This is a total newbie question but can that code make it to the next release? I seem to have hit this solution more than once (after debugging for an hour or so of course...).

Still love this module!

pcambra’s picture

Status: Closed (fixed) » Active
StatusFileSize
new836 bytes

This is not fixed because the patch provided by torgosPizza hasn't been applied in the dev version.

I'm attaching a patch both for 1.21 & dev version

torgospizza’s picture

Ah, the fact that it was marked as fixed would be why the patch didn't make it in. :) Thanks for reposting the patch, I'll roll it in next chance I get.

alexgreyhead’s picture

Status: Active » Needs review

The patch at #4 mentions the $nid variable as a way of making sure the current node isn't included in the upsell module's recommendations, but $nid doesn't exist there (it's used earlier, but won't be valid now).

Perhaps it should be:

$filter_query = implode(",", array_merge($ary, uc_upsell_get_cart_nids(), array((arg(0) == 'node' && is_numeric(arg(1))) ? arg(1) : 0)));

? (Seems to work for me here, but of course YMMV).

torgospizza’s picture

Status: Needs review » Fixed

Thanks! I put the line from #12 into the -dev version.

Status: Fixed » Closed (fixed)

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

Infinitee’s picture

I have the latest 6.x-1.x-dev version and everything else is up to date but, I am still getting this error.

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 ') ORDER BY RAND()' at line 5 query: SELECT `nid` FROM node WHERE `status` = 1 AND `type` IN ('product','product_t_shirt') AND NOT nid IN () ORDER BY RAND() in /nfs/c07/h01/mnt/109367/domains/drupal6/sites/pearlessenceshop.com/modules/uc_upsell/uc_upsell_core.inc on line 215.

torgospizza’s picture

Hmmm... not sure what the best way is to fix this. To be honest I want to completely rewrite this module in a 2.x using Views, since that's pretty much the way everything is going. If I get some time this weekend I'll try to troubleshoot and fix this, though.

Thanks!

train’s picture

Here's what I've been able to find after being hit by this recently...

On line 208 $filter_query is being generated using array_merge. uc_upsell_get_cart_nids() returns an empty array if there's nothing in the cart. It looks like if one of the arrays is empty or unset, array_merge does nothing and $filter_query is then empty.

So on line 215 when the SQL statement is called, the IN() portion on line 5 is empty and MySQL doesn't like that.

matthijs_hofstede’s picture

I ran in to this problem recently. After installing the dev version i had no problems anymore.

Dubber Dan’s picture

This sorted it for me using uc_upsell-6.x-1.21

ratinakage’s picture

I had this today. Installed dev, problem solved.