MySQL Query ( SELECT * FROM `tt_albums` WHERE `parentid`= ) failed.

Hello

I got an error when accessing my first album:
MySQL Query ( SELECT * FROM `tt_albums` WHERE `parentid`= ) failed.

It is the second time this happens. The first time I just reinstalled ZenPhoto and started over.

Now I would like not to start again...

I think I now know what is the cause of the problem, but don't know how to fix it.

At both occasions, I have created a sub-forum and, "by hand", manually transferred one of the photo from the main album to the sub-album. I thought that it was not forbidden because we can load an album using FTP, almost the same thing...

Is this related ? (Turning on the debug information doesn't seem to help).

Thanks

Gaston

Comments

  • When you do these "by hand" changes you should follow it by a database refresh. "by hand" changes will leave dangling entries for the old albums that could cause difficulties.

    BTW, Zenphoto does provide you the means to move an album to a different folder.
  • huogas Member
    About providing a mean to move album around, I knew it, but it was easier to do it manually (files operation. I won't do it again...

    I ran the database refresh, but I still get the message:
    Zenphoto encountered an error
    MySQL Query ( SELECT * FROM `tt_albums` WHERE `parentid`= ) 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 '' at line 1

    If it can help, let's say that if exit Admin and to the frontend, I still have the error on the first thumb display page, but when clicking on page 2, the error doesn't show up.

    Any idea ?

    Gaston
  • I guess you will have to tell us your Zenphoto version and what theme you are using. Needless to say, we are not seeing this issue.
  • huogas Member
    Here is the information:
    Zenphoto version 1.3 [5479] (Official Build)
    Current gallery theme: Default
    PHP version: 5.2.13
    Graphics support: PHP GD library bundled (2.0.34 compatible)
    PHP memory limit: 256M (Note: Your server might allocate less!)
    MySQL version: 5.0.90
    Database name: rimqnet_zenphoto
    Table prefix: tt_
    Spam filter: none
    CAPTCHA generator: zenphoto
    Gallery Stats
    246 Images
    4 Albums
    0 Comments

    Dans Gallery statistics, for a specific picture, if I click on View, the photo will be displayed. If I click on Edit, I will have the error message.

    Thanks for helping

    Gaston
  • Please find the following line at the beginning of functions-basic.php
    `define('DEBUG_ERROR', !defined('RELEASE')); // set to true to supplies the calling sequence with zp_error messages`

    change it to read
    `define('DEBUG_ERROR', true);`

    This will give us a trace of where the error is occurring. Perhaps that will shed some light on what is going wrong.

    The other thing you might try is to install the nightly build. When I say I am not seeing this, I should be specific--it is not occurring for me on the nightly build.
  • huogas Member
    Zenphoto encountered an error
    MySQL Query ( SELECT * FROM `tt_albums` WHERE `parentid`= ) 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 '' at line 1
    Backtrace:

    -> query (class-gallery.php [665])
    -> Gallery->sortAlbumArray (class-album.php [491])
    -> Album->getAlbums (admin-functions.php [417])
    -> genAlbumUploadList (admin-functions.php [424])
    -> genAlbumUploadList (admin-edit.php [484])

    `
    id parentid folder title desc date
    2 NULL retrouvailles-2010-arthur-gagnon retrouvailles-2010-arthur-gagnon NULL 2010-07-26 23:00
    9 NULL photos-individuelles photos-individuelles NULL 2010-07-27 22:21
    10 NULL droles-de-faces droles-de-faces NULL 2010-07-27 22:21
    11 NULL photos-de-groupe photos-de-groupe NULL 2010-07-27 22:21
    `
  • huogas Member
    `function sortAlbumArray($parentalbum, $albums, $sortkey='`sort_order`', $sortdirection=NULL) {
    if (is_null($parentalbum)) {
    $albumid = ' IS NULL';
    $obj = $this;
    } else {
    $albumid = '='.$parentalbum->id;
    $obj = $parentalbum;
    }
    if (($sortkey == '`sort_order`') || ($sortkey == 'RAND()')) { // manual sort is always ascending
    $order = false;
    } else {
    if (!is_null($sortdirection)) {
    $order = strtoupper($sortdirection) == 'DESC';
    } else {
    $order = $obj->getSortDirection('album');
    }
    }
    if (count($albums) == 0) return array();
    $sql = 'SELECT * FROM ' . prefix("albums") . ' WHERE `parentid`'.$albumid;
    $result = query($sql);`
  • huogas Member
    Setup
    About to create tables...
    Done with table create!
    Zenphoto encountered an error
    MySQL Query ( SELECT * FROM `zp2_albums` WHERE `parentid`= ) 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 '' at line 1
    Backtrace:

    -> query (class-gallery.php [665])
    -> Gallery->sortAlbumArray (class-album.php [491])
    -> Album->getAlbums (setup.php [81])
    -> checkAlbumParentid (setup.php [2248])
  • huogas Member
    After trying to recreate the database using the same root directory (with the above result), I finally started over with a new directory.
    It's ok now.

    I think that the problem started when I created an album with the name:

    `drole-de-face...`

    Please note the 3 dots at the end (were parts of the directory name). It seems to be what created the problem.

    Makes sense ?

    Gaston
  • acrylian Administrator, Developer
    That makes sense as dots normally indicate a file suffix and may have confused your server setup.
  • huogas Member
    I'm not that sure that the server is the problem. If so, there will be a lot of problems.

    Let's suppose that you have a directory ending with dots, are you sure that this situation will be handled correctly by the sorter function ? The sorter function will not suppose that there is a sub-album, therefore a parent, but a parent inexistent in the db ? Just trying to make sure that there is not a @bug@.

    Thanks

    Gaston
  • acrylian Administrator, Developer
    Well, I would never use dots in any file (except for the suffix) or folder name as I would not special chars (to be on the secure side). I have no real idea what goes wrong for you but since you say it started with that name with the dots..

    Album titles and names are independent, so if you really need "drole-de-face..." use it as a title and "drole-de-face" as a name.

    Regarding sortAlbumArray() I think sbillard will be able to tell more (I am not familiar with that one right now).
  • huogas Member
    Thanks

    You are right about using dots. But, as we saw it, it could happens: I did it even if I'm not supposed to do it. May be that ZP should check more what the names are ?

    Anyway, the incident is closed, but the problem still has to be addressed.

    Thanks for your support,

    Gaston
  • huogas Member
    By the way, I forgot to say that it's a great software. I like it.

    Gaston
  • This was definately caused by the "..." in the file name. Zenphoto will treat that as an invalid album. Unfortunately, most of Zenphoto does not check to see if an album instantiation was successful. So you get "down stream" errors likt this one.
Sign In or Register to comment.