Hello,

I get the following error with Captcha Image :

    * user warning: 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 ' status = 0' at line 1 query: SELECT solution FROM captcha_sessions WHERE csid = 12, status = 0 in /server/homes/anselm/source/applications/wri-site/modules/captcha/captcha.pages.inc on line 143.
    * CAPTCHA test failed (unknown csid).

The fix is simple ; in captcha.pages.inc on line 143 change :

  $solution = db_result(db_query('SELECT solution FROM {captcha_sessions} WHERE csid = %d, status = %d', $csid, CAPTCHA_STATUS_UNSOLVED));

to :

  $solution = db_result(db_query('SELECT solution FROM {captcha_sessions} WHERE csid = %d AND status = %d', $csid, CAPTCHA_STATUS_UNSOLVED));

:) Thanks for this useful module.

Comments

nickbits’s picture

I was getting the same error, then after making the change noted above all I now get is

The answer you entered for the CAPTCHA was not correct.

.

I am use re-captcha, but it is definatly this module causing the problem as re-captcha has not been updated. The code I am entering is correct.

soxofaan’s picture

Thanks,
weird I didn't catch the problem myself

http://drupal.org/cvs?commit=162805

at nickbits: can you try with the math CAPTCHA and image captcha?

thanks for testing

nickbits’s picture

Hi,

I have downloaded the updates, run a cron and update and can confirm both the Math and image captchas work. The re-captcha dosn't. I know this has aso been raised in the re-captcha issues as well. I have assumed it is something to do with the captcha module as the re-captcha module has not been updated for several months and it is only since upgrading captcha that it has stopped working.

Cheers,
Nick

nickbits’s picture

Hi,

I have switched back to CAPTCHA 6.x-1.0-rc2, which seems to be working fine.

Nick

JohnnyMoney’s picture

Getting :CAPTCHA test failed (unknown csid). with math test in contact form. Haven't tried image captcha yet. Using captcha-6.x-2.0-beta1.tar

Will revert to previous version for now hoping it works.

soxofaan’s picture

Status: Active » Fixed

hmm, there are too much different unrelated problems in this thread,
I think it's best to close this one, since the original issue about SQL syntax error is fixed

Concerning the problem with ReCAPTCHA: there is a dedicated thread #356407: reCAPTCHA doesn't works with CAPTCHA 6.x-2.0-beta1

at JohnnyMoney: I can't reproduce your problem, please retest if possible and open a new issue with more thorough instruction on how to reproduce the issue (do not comment in this thread please)

ClearXS’s picture

I have the same error and ONLY installed the 6.x-2.0-beta1 release. I've looked in my download dir to be sure, but no earlier captcha and no recaptcha present. Because it took me some time to find this page, I'll include the full error message, so others might find this page easier on googling:
* The CAPTCHA field is required.
* user warning: 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 ' status = 0' at line 1 query: SELECT solution FROM captcha_sessions WHERE csid = 109, status = 0 in .../sites/all/modules/captcha/captcha.pages.inc on line 143.
* CAPTCHA test failed (unknown csid).
(I left out my sites specific data, like my drupal database prefix => d1_captcha_sessions, & my sites name/drupaldir)

I dont know what to do. Even if I would degrade to an earlier version, I'm afreight that this damages again my drupal installation and I have to reinstall again, what means I have to cancel the whole drupal proyect, because I already had -due to obligations- to leave last week to another country where is very poor internet. That's 2 days work with 200 modules and checking them, or sometimes not, throttle, or sometimes no throttle, etc. If I do something wrong, I have to reinstall my databases too and loose all the data (its a testsite, so thats only another day work, not weeks). But these modules inflicting drupal instability and derailment continues for over two weeks of full working days on it now: http://drupal.org/node/357667

Is there a safe way to deinstall and reinstall/degrade? How about the changes to the database? Yes; one error and there we go again.

// $Id: image_captcha.install,v 1.6 2008/03/20 10:37:09 soxofaan Exp $
* On uninstall: remove module variables and clear variable cache
function image_captcha_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'image_captcha_%'");
cache_clear_all('variables', 'cache'); }

Will try something very soon; start praying (but never was religious before..).

ClearXS’s picture

Status: Fixed » Active

at nickbits: can you try with the math CAPTCHA and image captcha?

Unfurtunately I had the image for new sign-ups AND the math for every login. So I can't get into my drupal install too:

* user warning: 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 ' status = 0' at line 1 query: SELECT solution FROM d1_captcha_sessions WHERE csid = 112, status = 0 in .../sites/all/modules/captcha/captcha.pages.inc on line 143.
* CAPTCHA test failed (unknown csid).
* Sorry, unrecognized username or password. Have you forgotten your password?

ClearXS’s picture

THANKS for building into captcha, that after (re)moving the dir captcha under modules, I just can login as normal!!!

Now how to solve the database problem, before installing again?

I just removed them: (prefix_)captcha_points & (prefix_)captcha_sessions, with phpMyAdmin on my hostserver, after "exporting" these two to my PC, so I theoretically can import them again into the database on errors.

reinstalled 6.x-2.0-beta1 & update.php:

user warning: Table 'cyborg_d1.d1_captcha_points' doesn't exist query: SELECT module, type FROM d1_captcha_points WHERE form_id = 'update_script_selection_form' in /home1/cyborg/public_html/d/sites/all/modules/captcha/captcha.module on line 179.

unchecking the captcha modules of this release, then to modules->uninstall:
Luckely captcha is there, checking to uninstall=>

* user warning: Unknown table 'd1_captcha_points' query: DROP TABLE d1_captcha_points in .../includes/database.mysql-common.inc on line 261.
* user warning: Unknown table 'd1_captcha_sessions' query: DROP TABLE d1_captcha_sessions in .../includes/database.mysql-common.inc on line 261.
The selected modules have been uninstalled.

Not a big deal I hope, since it only couldnt drop what I had alrady dropped.

update.php => no more erors

extracting the same captcha module + checking them + update.php
Add CAPTCHA administration links to forms => yesX
image_capture for user-register.

* The CAPTCHA field is required.
* user warning: 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 ' status = 0' at line 1 query: SELECT solution FROM d1_captcha_sessions WHERE csid = 2, status = 0 in .../sites/all/modules/captcha/captcha.pages.inc on line 143.
* CAPTCHA test failed (unknown csid).

No, the module is wrong. I delete it permanently. Might install the former version and see if I've the same errors.

soxofaan’s picture

Status: Active » Fixed

at ClearXSClearXS:
there is indeed a bug in 6.x-2.0-beta1, which is fixed in CVS (not visible to normal users yet)

there will soon be a 6.x-2.0-beta2 release

but if you can't wait, you can already find a fixed version of beta1 at:
http://drupal.org/node/358875#comment-1200732

ClearXS’s picture

Status: Fixed » Active

Thanks! Drupal can do it all, but this site doesn't make it easy to find THE leads from the the module page...

First time I'd been able to uninstall a conflicting module without having to reinstal drupal + databases + all the checking again, so that is the breaking point for me, like some beginner certificate in order being able to succesfully administer a Drupal site.

And should I wait? Thanks to your sql logfile, I could see that already during installation -next to only my IP's- I have unwanted visitors from Defence &USgov allied Savvis (contact them; they might offer money to build in a backdoor..!) , together with an 'anonymous' Bahnhof IP from Stockholm where is the old NATO's listening headquarters for the USSR. Yes, they tried to get in. I'm only an information freedom activist, but I have to fight them first for that goal. Before I'd to spend 6 hours a day investigating and blocking similar IP's of all kinds of services and allied subversive groups on another site, during the Oaxacan revolt.

Over & out.

ClearXS’s picture

Title: MySql Syntax error » MySql Syntax error; closed/fixed
Status: Active » Fixed

(I'm sorry: the status had automatically changed as it was like that in my screen)

soxofaan’s picture

Issue is now also fixed in the development release (aka nighly build) 6.x-2.x-dev at http://drupal.org/node/94922

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.