printMostPopularItems() incorrect MySQL syntax

Hi,

I'm trying to make use of the printMostPopularItems() function in Zenpage. I'm having no luck as it just generates the following error:

`MySQL Query ( SELECT id, title, titlelink, hitcounter, total_votes, rating FROM `zp_zenpage_news` ORDER BY DESC LIMIT 10 ) failed. MySQL returned the error 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 'DESC LIMIT 10' at line 1`

This occurs on a FreeBSD box (Apache) running MySQL 5.0.51a and also a Windows box (Apache) running MySQL 5.1.30.

Unfortunately as I'm no MySQL guru I'm not sure where to start looking to debug it. Perhaps it'll be blindingly obvious to someone.

Cheers!

Comments

  • What version of Zenphoto are you running?
  • I'm running 1.3 (5479).
  • Could you post the actual code where you call printMostPopularItems()? Most likely this is caused by a parameter error.
  • acrylian Administrator, Developer
    I can confirm that a bug sneaked into that function. It will be corrected in the svn soon.
  • Ah that's good to hear :). Thanks a lot for your help!

    Is it a quick fix? As in, can I edit the function myself to get it working in my current installation?

    Cheers
  • acrylian Administrator, Developer
    Well, look at the function at the switch at the beginning. It checks $option but should actually check $mode.
  • I've tweaked it...

    `
    function getZenpageStatistic($number=10, $option="all",$mode="popular") {
    global $_zp_current_zenpage_news, $_zp_current_zenpage_pages;
    $number = sanitize_numeric($number);
    switch($mode) {
    case "popular":
    $sortorder = "hitcounter"; break;

    ...
    `
    ...and it now works :)

    Thanks a lot for that, well spotted!

    On a side note, it would be nice if the printZenageStatistic() that the printMostPopularItems() uses didn't add `$item['type']`, or at least gave the option to toggle, but that's something for another day I think. Given that I'm editing the functions page anyway I'll just delete it from there but in the future I'll put the php to use with getZenpageStatistic() directly in the theme.
  • acrylian Administrator, Developer
    Actually there is the get variant for such customisations. But we could take that out, too.
Sign In or Register to comment.