ZenphotoCMS Forum
printLatestUpdatedAlbums() - error on showdate = true - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: printLatestUpdatedAlbums() - error on showdate = true (/thread-12756.html)



printLatestUpdatedAlbums() - error on showdate = true - melbe - 2015-06-21

Hello!
I hope maybe you can help me - whenever I call printLatestUpdatedAlbums() and set $showdate = true I get the following error:

[i] Fatal error: MySQLi Error: ( SELECT COUNT(*) FROM [prefix]images WHERE albumid = 39 AND mtime = ) failed. MySQLi 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 '' at line 1 in /....../zp-core/functions-db-MySQLi.php on line 78 [/i]

For example :
printLatestUpdatedAlbums(5,true, true, false, 40, '', NULL, NULL, NULL, '', false, false);

Everything works fine as long as $showdate is false.
The error seems to happen in image_album_statistics.php :
function printAlbumStatisticItem(...)
within
if ($showdate) { if ($option === "latestupdated") { ...
[b] Line 260: [/b]'$count = db_count('images', "WHERE albumid = " . $tempalbum->getID() . " AND mtime = " . $latestimage['mtime']);'

I'm not sure - but it appears that something is wrong in line 259 here:
$latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $tempalbum->getID() . " AND show = 1 ORDER BY id DESC");
Because it seems in the line 260 $latestimage['mtime']);' is empty?And that messes up the SQL Syntax?

Appreciate any help, thank you!




printLatestUpdatedAlbums() - error on showdate = true - acrylian - 2015-06-21

We will have to take a look. It seems that "mtime" is empty which would mean the first query does not return any latest image. Did you check what $latestimage contains?




printLatestUpdatedAlbums() - error on showdate = true - melbe - 2015-06-21

Hi acrylian, thank you!
I just checked - var_dump($latestimage) is NULL.




printLatestUpdatedAlbums() - error on showdate = true - acrylian - 2015-06-22

I could reproduce it. The support build should have a fix.




printLatestUpdatedAlbums() - error on showdate = true - melbe - 2015-06-26

Thank you so much acrylian - finally had time to get the support build - perfect! Thank you for fixing it!