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
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | uc_upsell_687032-dev.patch | 836 bytes | pcambra |
Comments
Comment #1
jantoine commentedThis is also present in the latest dev snapshot.
Cheers,
Antoine
Comment #2
jantoine commentedI 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
Comment #3
torgospizzaSo 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.
Comment #4
torgospizzaYeah, try this. At line 208, change this line:
to this:
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.
Comment #5
mrvoo commentedthanks for your line - it works for me.
Comment #6
jantoine commentedThe fix in #4 fixes the issue, thus I am marking it as fixed. Thanks for the quick reply!
Cheers,
Antoine
Comment #8
dreadfulcode commented#4 Works.
Same error message, applied the code, bye bye error.
Thanks
Comment #9
ahimsauziSame 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!
Comment #10
pcambraThis 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
Comment #11
torgospizzaAh, 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.
Comment #12
alexgreyhead commentedThe 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:
? (Seems to work for me here, but of course YMMV).
Comment #13
torgospizzaThanks! I put the line from #12 into the -dev version.
Comment #15
Infinitee commentedI 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.
Comment #16
torgospizzaHmmm... 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!
Comment #17
train commentedHere'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.
Comment #18
matthijs_hofstede commentedI ran in to this problem recently. After installing the dev version i had no problems anymore.
Comment #19
Dubber Dan commentedThis sorted it for me using uc_upsell-6.x-1.21
Comment #20
ratinakage commentedI had this today. Installed dev, problem solved.