smudgespot
Forum Replies Created
-
Forum: Plugins
In reply to: [Visual Form Builder] Random entries are not being savedI’m not sure when this thread was marked as Resolved but sorry Joseph, it’s still a problem.
Well, until now that is! 🙂
After encountering this issue yet again, I finally did a lot of troubleshooting on the server and database but was not seeing any errors. Then I dug into the VFB code and found the problem. Before I was losing at least 50% of the registration entries on each form I created. Using my fix below, I’ve had 100% complete registrations and no more issues.
With all due respect to @mmuro and his work, the issue isn’t specifically VFB’s coding but due to an intermittent failure of the very common WordPress function
wpdb->insert()that he is using in VFB. Go do a web search for “wordpress insert” and “not working” or “failure” and you will see many discussions about the insert function failing.So to fix the problem, we need to replace the insert with a proper SQL prepare and query statement.
Edit the
wp-content/plugins/visual-form-builder/includes/email.phpfile.
On line 313, remove$wpdb->insert( $this->entries_table_name, $entry );
and replace it with the following code$result = $wpdb->query($wpdb->prepare(" INSERT INTO $this->entries_table_name (<code>form_id</code>, <code>data</code>, <code>subject</code>, <code>sender_name</code>, <code>sender_email</code>, <code>emails_to</code>, <code>date_submitted</code>, <code>ip_address</code>) VALUES ( %d, %s, %s, %s, %s, %s, %s, %s ) ", $entry )); if( $result === 1 ) : $sqlresult .= sprintf('<tr><td><strong>%1$s: </strong></td><td>%2$s</td></tr>' . "\n", "SQL Result", "Insert Successful"); else : $sqlresult .= sprintf('<tr><td><strong>%1$s: </strong></td><td>%2$s</td></tr>' . "\n", "SQL Result", "Insert Failed. error:" . $wpdb->last_error ); $sqlresult .= sprintf('<tr><td><strong>%1$s: </strong></td><td>%2$s</td></tr>' . "\n", "SQL Query", $wpdb->last_query ); endif;Then on line 326, remove
$message = $header . $body . $footer;
and replace it with$message = $header . $body . $sqlresult . $footer;Save the file and exit the editor.
If the above code blocks don’t appear proper or you have problems editing the file, you can download the fixed version VFB-email-fix.zip. This is only the email.php file with the above changes.
So, besides replacing the
insertfunction withprepareandquery, this code change also includes debug info in the email. Note: This info is ONLY in the confirmation email that is sent to you (Form settings>Email section> Emails To). The customer that filled out the form does not see it.When successful, it adds “SQL Result: Insert Successful” to the HTML table.

If it fails, the complete error message is shown as well as the full SQL query it tried to send. Here is an example where I intentionally made an error.

@josparky I hope this helps you and anyone else that has encountered this frustrating issue.
@josephk77 and/or @mmuro, I hope you can include this fix in the next release of your product. If you are thankful for this fix, I’d be grateful for a VFB Pro license 😉
- This reply was modified 9 years, 4 months ago by smudgespot.
- This reply was modified 9 years, 4 months ago by smudgespot.
Forum: Plugins
In reply to: [Visual Form Builder] Random entries are not being savedDoes VFB put the data into the database before or after sending the confirmation email?
I see them in my Sent Mail box so it is making it that far.I’ve run database integrity checks and there were no problems.
Forum: Plugins
In reply to: [Visual Form Builder] Random entries are not being savedI’ve looked through the web server logs but those only show web page access, nothing about VFB script failures.
Does VFB have a log file, perhaps with debug options? If not, perhaps that would be a good feature to add, of course as a setting the admin can enable.
Also, VFB should check if the database write failed or not and if so, it should send an email to the admin notifying them of the failure, any errors messages, and include the contents of the form submission.