zp_images uses MySQL reserved word as fieldname

`

mysql> select version();

+---------------------------------+

| version() |

+---------------------------------+

| 5.0.22-Debian_0ubuntu6.06.3-log |

+---------------------------------+

mysql> desc zp_images;

+-----------------------+------------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+-----------------------+------------------+------+-----+---------+----------------+

| id | int(11) unsigned | NO | PRI | NULL | auto_increment |

| albumid | int(11) unsigned | NO | MUL | 0 | |

| filename | varchar(255) | NO | MUL | NULL | |

| title | varchar(255) | YES | | NULL | |

| desc | text | YES | | NULL | |

| location | tinytext | YES | | NULL | |

| city | tinytext | YES | | NULL | |

| state | tinytext | YES | | NULL | |

| country | tinytext | YES | | NULL | |

| credit | tinytext | YES | | NULL | |

| copyright | tinytext | YES | | NULL | |

| tags | text | YES | | NULL | |

| commentson | int(1) | NO | | 1 | |

| show | int(1) | NO | | 1 | |

^^^^

mysql> select show from zp_images;

ERROR 1064 (42000): 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 'show from zp_images' at line 1

`

Because of this the 'Visible' flag for the individual photos in Albums does not work.

I can change the field name in to something different.

But can someone tell me which scripts/what line numbers that I need to change to make it work?

I am using zenphoto version 1.1.4.

For your reference:
Reserved Words in MySQL 5.0
http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-0.html

Further even the zp_albums also uses the reserved keyword 'show' as a fieldname:

`

mysql> desc zp_albums;

+---------------------+------------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+---------------------+------------------+------+-----+---------+----------------+

| id | int(11) unsigned | NO | PRI | NULL | auto_increment |

| parentid | int(11) unsigned | YES | | NULL | |

| folder | varchar(255) | NO | MUL | NULL | |

| title | varchar(255) | NO | | NULL | |

| desc | text | YES | | NULL | |

| date | datetime | YES | | NULL | |

| place | varchar(255) | YES | | NULL | |

| show | int(1) unsigned | NO | | 1 |

^^^^^^^

`

A good practice is to have some prefix for each field to avoid this kind of mistakes.

Comments

  • acrylian Administrator, Developer
    No, the real trick is to set a reserved word within backticks what we do in every query then it's very well allowed.

    If you got an error with a fresh zenphoto installation please tell us on which action that happened in case that we really missed that anywhere. Thanks.
  • OK. Thanks for the explanation. The issue I had was that when I mark individual images as not Visible, they were still shown in Album view.

    I was under the impression that your scripts may not be reading the flag because of the 'show'.

    Now I figured out that the flags are effective only if you have logged out as Admin.

    Is there a way to change that behavior?

    I am using zenphoto to selectively display some of the images that are stored in my NAS device in my home network. I just create soft links to the actual location of folders from the albums folder. Then I want to be able to decide which image to be shown and which image not to be shown.

    If I have the ability to see exactly what the user see while logged in as Admin it would be quite convenient.
  • If you change the behavior to not show the images when logged in you will have problems with any administration functions on the image--it won't show.

    There are some tags associated with the image, forget the exact wording, that are set when an image is marked not visible. You could have your css supress them.

    Otherwise, open another browser that is not logged in and use it to view as a user. That way you will also see if there are differences between the browers, say IE and FireFox.
  • Got it:
    class="not_visible"

    thanks
Sign In or Register to comment.