We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19004
    • 33 Posts
    I’m running modx v0.92 on windows xp, with MaxiGallery v0.4.1. The issue is when I try to upload images on a page with the MaxiGallery snippet tag. What is happening is that I get a parsing error that looks like this:

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - Field 'title' doesn't have a default value »
          SQL: INSERT INTO `modxdemo`.modx_maxigallery(id, gal_id, filename, date) VALUES(NULL,'38','scenic005.JPG',NOW()) 
    


    I searched the forums for this parsing error but I couldn’t find anything. Any ideas? I’m not very savvy with this kind of thing.

    This is what I put in my page:

    <p>Before Gallery</p>
    [[MaxiGallery? &display=`embedded` &embedtype=`slidebox` &pics_in_a_row=`3` &max_thumb_size=`110` &max_pic_size=`0` &thumb_use_dropshadow=`1`]]
    <p>After Gallery</p>
      • 7923
      • 4,213 Posts
      This is the first time I hear about this.. must be if MySQL is running in some strict mode or something.. anyways, 2 options comes to my mind: 1. First option would be to edit your modx_maxigallery table and set title field default to null and remove not null. Don’t know why it’s even set to be not null.. (i’ll fix that). 2. The second option would be to edit functions.php and change:

      this:
      $rs1=$modx->db->query("INSERT INTO " . $pics_tbl . "(id, gal_id, filename, date, own_id) VALUES(NULL,'" . $gal_id . "','" . $name . "'," . $pic_date . ",'".$modx->getLoginUserID()."')");
      


      to:
      $rs1=$modx->db->query("INSERT INTO " . $pics_tbl . "(id, gal_id, filename, title, date, own_id) VALUES(NULL,'" . $gal_id . "','" . $name . "',''," . $pic_date . ",'".$modx->getLoginUserID()."')");
      


      and this:
      $rs1=$modx->db->query("INSERT INTO " . $pics_tbl . "(id, gal_id, filename, date) VALUES(NULL,'" . $gal_id . "','" . $name . "'," . $pic_date . ")");
      


      to this:
      $rs1=$modx->db->query("INSERT INTO " . $pics_tbl . "(id, gal_id, filename, title, date) VALUES(NULL,'" . $gal_id . "','" . $name . "',''," . $pic_date . ")");
      


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
      • Yes, that is because your mysql is set to "strict" mode. If a field is set to NOT NULL, it must have a value. It should have been given a "default = ’’ " when the table was originally created.

        This is something snippet and module developers need to keep in mind when creating tables for their apps; we’re going to see more and more of this as the hosting companies upgrade their mysql versions. If your table description has NOT NULL, be sure to give it a default value!
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 7923
          • 4,213 Posts
          Yes, that table creation code is legacy from etogal and I will fix it for the next version. This snippet is not very well "optimized" codewise. I think that I will only do one more version of this snippet that has the features implemented that are in tickets in MaxiGallery Trac currently. (and bugfixes after that if needed) The next version will use TBS for templating. But I haven’t been doing any developing with this lately when I noticed that there isn’t much request for the new version (from the language file thread).

          I’ve been wanting to do a new lighter and more modular gallery snippet from scratch that will probably be available for MODx 1.0. Or maybe littlebit sooner, but It’s definitely going to take advantage of xPDO and will have a better designed architecture from start what is easier to maintain. This version will also use native MODx tempating system, eg. placeholders and maybe some new features that are coming in future MODx versions. But this all takes time and I haven’t had much freetime lately..


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 19004
            • 33 Posts
            Changing functions.php did the trick. Thanks!