• Hello..

    Just installed this great plugin but get lots of DB warnings in my debug-log:

    [26-Mar-2019 13:33:44 UTC] WordPress database 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 for query INSERT INTO wp_lightbox_photoswipe_img (imgkey, created, width, height) VALUES (“4b445689ab5ca210f86dcd3cdc1c61f1-0”, “2019-03-26 13:33:44”, , ) made by shutdown_action_hook, do_action(‘shutdown’), WP_Hook->do_action, WP_Hook->apply_filters, wp_ob_end_flush_all, ob_end_flush, LightboxPhotoSwipe->output, preg_replace_callback, LightboxPhotoSwipe->outputCallback

    Error appear when visiting single products page (woocommerce).

    Any idea?

    Brgds
    Rune

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter ArcticFritid

    (@metuza)

    I found a fix.. In line 274 of lightbox-photoswipe.php i replaced this line:

    $sql = "INSERT INTO $table_img (imgkey, created, width, height) VALUES (\"$imgkey\", \"$created\", $imagesize[0], $imagesize[1])";
    
    with this line:
    $sql = "INSERT INTO $table_img (imgkey, created, width, height) VALUES (\"$imgkey\", \"$created\", \"$imagesize[0]\", \"$imagesize[1]\")";

    Seems like evrything works just fine now.

    Rune

    Plugin Author Arno Welzel

    (@awelzel)

    I’ll add some more tests to avoid this error – but generally Lightbox with PhotoSwipe can not be used together with WooCommerce, since WooCommerce already has a lightbox integrated.

    At the moment you can only disable Lightbox with PhotoSwipe or try to implement a workaround as described in the FAQ. However, on product WooCommerce product pages my plugin can not be used.

    Edit: Your fix just avoids the error message. But the whole SQL command MUST NOT be executed at all if the image sizes could not be determined. This way you will just fill your database with garbage, sorry.

    I’ll prepare an update which will stop the plugin from proceeding at all, if the image size could not be determined – because in this case the lightbox would not work anyway. Without an image size, Photoswipe will not work.

    • This reply was modified 5 years, 12 months ago by Arno Welzel.
    Thread Starter ArcticFritid

    (@metuza)

    It did not add image size to DB before i added the slashes to DB query. Now it does add both with and height to DB and works perfectly fine with the products i need to use it.

    These are some bundled products displayed by a YITH plugin. All other products uses my themes lightbox function.

    So everything seems to work 100% now.

    Plugin Author Arno Welzel

    (@awelzel)

    It now does also not add any image size to the DB. The executed statement will now be:

    INSERT INTO wp_lightbox_photoswipe_img (imgkey, created, width, height) VALUES ("4b445689ab5ca210f86dcd3cdc1c61f1-0", "2019-03-26 13:33:44", "", "")

    There is no size at all. Just a key and date, nothing else. Just have a look at the database table wp_lightbox_photoswipe_img – you will find many records with completely empty width and height.

    Those images which work, are those, where the DB statement was ok, because the image size could be determined. But there are still many other images created by WooCommerce which will not work and just create useless garbage in the database.

    That’s why I said, the fix is not really a fix. I will address this with the next update. However, using WooCommerce together with Lightbox with PhotoSwipe is not recommended at all since both add lightbox scripts which can result in a number of problems at runtime.

    Thread Starter ArcticFritid

    (@metuza)

    Ok, now i see what you mean.. The imagekey size/width is inserted to DB just on page visit and if no imagesize set the insert set 0 width and height and no complete key.

    So i have added a check, if no width and height no insert to db.

    Works great now after checking blog, products and other pages with images. No more db entries created. Only the needed images has now entry in DB.

    In regards to conflicts i just have to keep an eye with that. So far it works great.

    Plugin Author Arno Welzel

    (@awelzel)

    Just for the records: Lightbox with PhotoSwipe will clean up its database entries which are older than 24 hours automatically, so you don’t have to worry that your database will grow forever. The database is just used to cache the image sizes and reduce the server load.

    Thread Starter ArcticFritid

    (@metuza)

    Ok, sound nice.. Just checked with woocommerce and they deprecated the use of lightbox from version 3.0 and now use its own script.

    Thanks.

    Plugin Author Arno Welzel

    (@awelzel)

    I just released version 1.96 which should fix this error.

    Thread Starter ArcticFritid

    (@metuza)

    Yes, works just great ??

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘WordPress database error’ is closed to new replies.