Forums

Contact Form 7 to Database Extension
[resolved] Individual delete not working (24 posts)

  1. nascent666
    Member
    Posted 1 year ago #

    Hi. I installed the latest version of Contact Form 7 (Version 2.4.4) and Contact Form to DB Extension (Version 1.8). I'm using WordPress 3.1 and I am set up as the Admin. When I go to delete a single record, I click the checkbox and hit the delete button in the row heading. The page refreshes, but the record is still there.

    I can click the "Delete All This Form's Records" button to remove all the records and I can delete the records via phpMyAdmin.

    Can you look to see if the delete record has a bug in it?

  2. Michael Simpson
    Member
    Posted 1 year ago #

    That is a bug in my code. I will push an update of the plugin with a fix shortly. Thanks for letting me know.

  3. nascent666
    Member
    Posted 1 year ago #

    Almost there. I installed 1.8.1 and when I went to the listing or records, I was able to delete a single one. Then when it refreshed the page, I couldn't delete anymore consistently. Also, it doesn't seem to delete, say 2 out of 3.

    Once, I chose 3 of 5 records and it only deleted one, which I think was the oldest record, but that seemed to be a fluke since I couldn't replicate that.

    Not sure if it's me at this point or the plugin.

    BTW...I'm using FireFox 3.6.15

  4. wreston
    Member
    Posted 1 year ago #

    Michael, Bump! I've got the same problem. Using V 1.8.1, I am unable to delete records. I am using IE8. Thanks...

  5. Michael Simpson
    Member
    Posted 1 year ago #

    This is related to a database change. I think you can delete entries made pre-1.8 but not after. That is because entries made after have a submit time with a decimal value (microsenconds) and that is not being seen in the form for some reason.

    Go to your Database admin page, and view the page source. Look for something like this (but the number will be different).

    <input type="checkbox" name="1300155590.3113" value="row"/>

    Do these tags have "name" numbers with decimals? Are they always ".0000"?

  6. nascent666
    Member
    Posted 1 year ago #

    They have the decimals:

    <input type="checkbox" name="1300798323.9905" value="row"/>
    <input type="checkbox" name="1300798309.3054" value="row"/>
    <input type="checkbox" name="1300798290.1642" value="row"/>

    I've only created test accounts from 1.8 and above. All these are from 1.8.1 since I cleared the database before making these.

  7. Michael Simpson
    Member
    Posted 1 year ago #

    Are you willing to do some debugging?

    Edit the plugin file CF7DBPlugin.php

    look for:

    $name = str_replace('_', '.', $name);
    $wpdb->query(
    	$wpdb->prepare(
    		"delete from <code>$tableName</code> where <code>form_name</code> = '%s' and <code>submit_time</code> = '%s'",
    		$currSelection, $name));

    and insert an "echo" line so it becomes:

    $name = str_replace('_', '.', $name);
    echo $wpdb->prepare(
    		"delete from <code>$tableName</code> where <code>form_name</code> = '%s' and <code>submit_time</code> = '%s'",
    		$currSelection, $name);
    $wpdb->query(
    	$wpdb->prepare(
    		"delete from <code>$tableName</code> where <code>form_name</code> = '%s' and <code>submit_time</code> = '%s'",
    		$currSelection, $name));

    Then try a deletion. It will show the SQL statement near the top of the page. Let's grab that and see what it look like.

  8. Michael Simpson
    Member
    Posted 1 year ago #

    That didn't print out right. Where it has a 'code' tag replace that with back-quotes (the one in the upper left of the keyboard).

  9. nascent666
    Member
    Posted 1 year ago #

    WP doesn't like the echo there. Doesn't show anything but a blank page, so there must be a php syntax error.

    However, I tried print_r as in:

    print_r ($wpdb->prepare(
    .....
    );

    and I got this when trying to delete two entries:

    delete from ~wp_CF7DBPlugin_SUBMITS~ where ~form_name~ = 'eNewsletter' and ~submit_time~ = '1300798323.9905'delete from ~wp_CF7DBPlugin_SUBMITS~ where ~form_name~ = 'eNewsletter' and ~submit_time~ = '1300798309.3054'

    Note: I replaced the backticks with ~ in this example so the code tags won't show.

  10. nascent666
    Member
    Posted 1 year ago #

    Follow-up

    I tried this statement directly in phpmyadmin and it didn't delete there:

    DELETE FROM ~wp_cf7dbplugin_submits~ WHERE ~submit_time~ = '1300798323.9905'

    but if I do a SELECT * FROM, I see the three results.

    If I do

    DELETE FROM ~wp_cf7dbplugin_submits~ WHERE ~form_name~ = 'eNewsletter'

    then all of the records get deleted. It's definitely related to the submit_time

  11. Michael Simpson
    Member
    Posted 1 year ago #

    You won't actually need the backquotes for the below:

    What do you get when you try:
    select submit_time from wp_cf7dbplugin_submits where submit_time = '1300798323.9905'

    Is it different if you drop the quotes around the number? (what is your MySQL version?)
    select submit_time from wp_cf7dbplugin_submits where submit_time 1300798323.9905

  12. nascent666
    Member
    Posted 1 year ago #

    It shows the three records with the same submit_time with or without the quotes.

    MySQL 5.0.67-community-nt

    I think you stumbled upon something. If I try to delete with quotes, like

    delete from wp_cf7dbplugin_submits where submit_time = '1300981171.0724'

    then it doesn't work. BUT, if you remove the quotes, it deletes the records:

    delete from wp_cf7dbplugin_submits where submit_time = 1300981171.0724

  13. nascent666
    Member
    Posted 1 year ago #

    From your code before, I removed the single quotes and I can now delete multiple rows.

    $wpdb->query(
                                    $wpdb->prepare(
                                        "delete from ~$tableName~ where ~form_name~ = '%s' and ~submit_time~ = %s",
                                        $currSelection, $name));
  14. Michael Simpson
    Member
    Posted 1 year ago #

    Thanks, I will get that fix in right away!

  15. nascent666
    Member
    Posted 1 year ago #

    Well...I tried 1.8.2 and I get inconsistent delete results. Sometimes it deletes all the ones I want, sometimes it deletes 1 of 3, or 2 of 4, but it always seems to leave two in the database.

    The delete all seems to work, though.

    Not sure if it's the plugin or my SQL database at this point, but I am able to delete the items in phpMyAdmin by using the SQL DELELE statement without quotes for the submit_time.

    Also, when I do the print_r in the code, I do see single quotes again, but I'm not sure where they are coming from.

    delete from ~wp_CF7DBPlugin_SUBMITS~ where ~form_name~ = 'eNewsletter' and ~submit_time~ = '1301319511.9545'

    I tried upgrading and completely removing the tables and doing a fresh install. I get the same results with any configuration/installment method.

    I also reverted back to my modified 1.8.1 version and tested it and I get inconsistent results there, too. So maybe removing the single quotes around the %s wasn't enough.

    When I do a print_r for just the $wpdb variable, this is SOME of what I see...

    ...
    wpdb Object (
    [last_query] => delete from ~wp_CF7DBPlugin_SUBMITS~ where ~form_name~ = 'eNewsletter' and ~submit_time~ = '1301319511.9545'
    ...
    [charset] => utf8 [collate] =>
    ...
    [func_call] => $db->query("delete from ~wp_CF7DBPlugin_SUBMITS~ where ~form_name~ = 'eNewsletter' and ~submit_time~ = '1301319511.9545'")
    )
    ...

    Maybe the collate needs to be set? I'm using utf8_inicode_ci. Other than that, I'm stumped.

  16. wreston
    Member
    Posted 1 year ago #

    Bump. I continue to have the same problem... I've updated to V1.8.2 but am still having problems deleting single records.

    Thanks...

  17. Michael Simpson
    Member
    Posted 1 year ago #

    One more thing to try, this line:

    "delete from ~$tableName~ where ~form_name~ = '%s' and ~submit_time~ = %s",

    change to
    "delete from ~$tableName~ where ~form_name~ = '%s' andsubmit_time= %d",

    (change the ending "%s" to "%d", this line appears twice)

  18. nascent666
    Member
    Posted 1 year ago #

    ok...tried it, but it's still not deleting. It's missing the decimal point and the four numbers after. However, this doesn't have the single quotes in it like the %s had.

    delete from ~wp_CF7DBPlugin_SUBMITS~ where ~form_name~ = 'eNewsletter' and ~submit_time~ = 1301331622

    %d = xxxxxxxxxx
    %s = 'xxxxxxxxxx.xxxx'

    So I guess now wehave to figure out where the single quotes are coming from with the %s.

  19. nascent666
    Member
    Posted 1 year ago #

    I looked at your code and did some research. I looked at sprintf and saw all the type specifiers. I tried %f and that seemed to work for me. I was able to delete without any problems and none stayed in my database.

    Can someone else confirm?

    it produces...
    ~submit_time~ = 1301410875.556900

    It added two zeros at the end, but it doesn't seem to affect the deleting.

  20. wreston
    Member
    Posted 1 year ago #

    nascent666, thanks! Looking good... I replaced the %s with %d (2 places) in the file CF7DBPlugin.php. I've only been able to do limited testing, but so far, the %F appears to correct the delete problem I was having. I am now able to delete single records created both before and after installing V1.8.0.

    I'm still having a problem with unwanted 'links' being displayed when using cfdb-table to display records that have been imported to wp_CF7DBPlugin_SUBMITS.

    http://wordpress.org/support/topic/plugin-contact-form-7-to-database-extension-link-on-data?replies=4

    Hopefully there is a simple solution...

    Many thanks!

  21. Michael Simpson
    Member
    Posted 1 year ago #

    Would you install unreleased Version 1.8.3RC1 and see how that works.

    I am using %F for the deletes and some other SQL.

    Does it have any effect on the extraneous links in your table? (It seems to be thinking that those fields are files that can be downloaded).

  22. nascent666
    Member
    Posted 1 year ago #

    I installed it and I'm able to delete single and multiple records. Also, I tried [cfdb-table form="eNewsletter"] in a test Post and I don't have any linking issues like wreston. I didn't thoroughly test anything else.

  23. wreston
    Member
    Posted 1 year ago #

    I've installed it as well. It corrects the problem that I was having when trying to delete records. Thanks!

    I still have the problem with the weird links. See this URL
    http://www.tacmissileers.org/?p=4014 They even occur on the admin screen.

    The links only occur on records that have been imported into wp_CF7DBPlugin_SUBMITS using phpMyAdmin. Records created via a Contact Form 7 input do not have the links. (Earlier, when having problems deleteing records, I used phpMyAdmin to drop wp_CF7DBPlugin_SUBMITS and then did a database import (SQL) to restore the table.)

    I've looked at the records using phpMyAdmin and can see no difference between one that has been imported into wp_CF7DBPlugin_SUBMITS vs. one that has been created via a Contact Form 7 submission. Is meta data stored somewhere for the records?

    Michael, if you try testing by dropping wp_CF7DBPlugin_SUBMITS and then restoring it via a phpMyAdmin import, can you recreate the problem?

    Thanks for all your help!

  24. nascent666
    Member
    Posted 1 year ago #

    I marked this as resolved since both issues were addressed. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic