Member
Member
rjscotland   2010-07-04, 20:38
#1

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 FROMzp_zenpage_newsORDER 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!

Member
Member
kagutsuchi   2010-07-04, 21:06
#2

What version of Zenphoto are you running?

Member
Member
rjscotland   2010-07-04, 21:56
#3

I'm running 1.3 (5479).

Member
Member
sbillard   2010-07-05, 00:12
#4

Could you post the actual code where you call printMostPopularItems()? Most likely this is caused by a parameter error.

Administrator
Administrator
acrylian   2010-07-05, 07:32
#5

I can confirm that a bug sneaked into that function. It will be corrected in the svn soon.

Member
Member
rjscotland   2010-07-05, 08:28
#6

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

Administrator
Administrator
acrylian   2010-07-05, 10:24
#7

Well, look at the function at the switch at the beginning. It checks $option but should actually check $mode.

Member
Member
rjscotland   2010-07-05, 15:01
#8

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.

Administrator
Administrator
acrylian   2010-07-05, 15:58
#9

Actually there is the get variant for such customisations. But we could take that out, too.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.