• Resolved nascent666

    (@nascent666)


    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?

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Author Michael Simpson

    (@msimpson)

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

    Thread Starter nascent666

    (@nascent666)

    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

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

    Plugin Author Michael Simpson

    (@msimpson)

    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”?

    Thread Starter nascent666

    (@nascent666)

    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.

    Plugin Author Michael Simpson

    (@msimpson)

    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.

    Plugin Author Michael Simpson

    (@msimpson)

    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).

    Thread Starter nascent666

    (@nascent666)

    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.

    Thread Starter nascent666

    (@nascent666)

    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

    Plugin Author Michael Simpson

    (@msimpson)

    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

    Thread Starter nascent666

    (@nascent666)

    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

    Thread Starter nascent666

    (@nascent666)

    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));
    Plugin Author Michael Simpson

    (@msimpson)

    Thanks, I will get that fix in right away!

    Thread Starter nascent666

    (@nascent666)

    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.

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

    Thanks…

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘[Plugin: Contact Form 7 to Database Extension] Individual delete not working’ is closed to new replies.