WordPress database error | Peter's Custom Anti-Spam for WordPress | Forum
Back to the custom anti-spam plugin page
9:32 pm
thank you for the great work!
my platform is ubuntu 7.10 + apache2 + PHP5+ mysql+wordpress 2.3+ Peter's custom antispam image plugin 2.9.4.
error when post a comment.
1. if i am a registed user, there is no error.
2. if i am a guest , no error for the first visit to the page.there is an anti-spanm image .
3. as a guest,if i reload the page for the page, there is an error like this:
WordPress database error: [Duplicate entry '0' for key 1]
INSERT INTO wp_cas_image (id, createtime, word) VALUES (0, 1191632776, 'share')
and, the word in the image is diffrent from the word in the error message.for example,word in the image is "rice",but the word in the message is "share". then, if i post a comment,there is a error messae like the following:
Error: Please enter the anti-spam word.
Copy your comment in case this site forces a page reload whenever you press the Back button:
4.as a guest , i don't need to input personal meessage such as name and email again when post another comment,if i have a comment Moderated by the manager. when i post a comment, there is no anti-spam image.but when posted, error again like this:Error: Please enter the anti-spam word.
Copy your comment in case this site forces a page reload whenever you press the Back button:
i created 2 tables manually sucessfuly.but error is same as step 2, 3, 4.
that's all, thank you.
This is stumping me because a few people have reported this...
Can you try finding this code in the plugin file:
// Insert a row into the count database to generate an auto_increment number
$wpdb->query('INSERT INTO ' . $cas_count . ' (id) VALUES (NULL)');
And replacing it with this:
// Insert a row into the count database to generate an auto_increment number
$wpdb->query('INSERT INTO ' . $cas_count . ' (id) VALUES (\\'AUTO_INCREMENT\\')');
Try also:
$cas_rowid = $wpdb->get_var('SELECT last_insert_id()');
instead of:
$cas_rowid = mysql_insert_id();
Because I can't reproduce this problem on my installation, I can't figure out whether the problem is in getting the ID of the last inserted row or inserting a row in the count table. So I just have to keep throwing random suggestions out there...
7:32 am
Your solution worked! thank you.
But, anohther issue:
As a anonymous ,if I've posted a comment ,when i post another comment,the anti-spam image & the input field would be hidden,such as the input field for name & emial & site .All of them would be hidden. then Error(Please enter the anti-spam word) appear again when post be submitted .
Because there is a cookie for anonymous, if anonymous posted a comment, WordPress allow anonymous that not to input name information again.
Now,anonymous would not input anti-spam word, until he CHANGE his information, then all input filed would appear agian,incuding anti-sapm filed.
I dont think that it's a bug.but, for commen user, they cant know how to post comment twice unless CHANGE information. That's not so human beings.
Maybe you would find a solution in the next version:)
my english is so poor, beg your pardon.
Thank you very much.I like this plugin very much.
Glad to hear it worked! But which piece of code worked? If you let me know, I can update the code for the next release so that the plugin is more compatible for different server setups.
Also, the behaviour with anonymous users -- is that with a plugin or did you use some built-in WordPress option? Would it be sufficient for you to use the manual insert method described here to force the anti-spam word to be displayed even for repeat users?
Where is your site so that I can do some investigation?
10:37 am
It worked with the 2nd way: modify $cas_rowid.....
And i tested, if both codes are modified, it worded too.
And ,for the behaviour with anonymous users ,it's WP's built-in option. In Options-Discussion-Before a comment appears,If "Comment author must have a previously approved comment" be checked.then the information field would be hidden.
i can manualy hacked the php file.
would you make it to be a option for the anti-spam plugin? for those guy who dare to modify code manualy? :P
my site is http://www.minibird.net ,welcome. but there's nothing in the site, :P
Thank you!
Hi, I was unable to duplicate that behaviour that you described. When I checked that option, no fields disappeared on the comment form for me when I was an anonymous user. However, the answer might lie in the manual insert method (which I recommend that everybody do for accessibility reasons).