I am trying to greate a poll for my website. I am getting this error when they user trys to vote and I dont understand why. The error appears to be on the processing page when trying to add votes. I get the total votes from the database then add 1 and then update the database. THat is when I get there error. can anyone help? Thanks.
CODE:
<!---BEGIN COLDFUSION CODE FOR POLL--->
<CFAPPLICATION NAME="Cookies"
sessionManagement = "Yes"
setDomainCookies = "Yes"
setClientCookies = "Yes">
<!---GET CURRENT POLL ID--->
<cfquery datasource="xxxxx" name="currentpollID" >
SELECT *
FROM OAREI_poll
WHERE start_date <= <cfqueryparam cfsqltype="cf_sql_date"
value=#Now()#> and end_date >= <cfqueryparam cfsqltype="cf_sql_date"
value=#Now()#>
</cfquery>
<cfset SESSION.display = #currentpollID.poll_ID#>
<!---END CURRENT POLL ID--->
<!---TEST TO SEE IF COOKIE EXISTS--->
<CFIF Not IsDefined ("cookie.OAREIpoll")>
<CFSET cookie.OAREIpoll = 0>
</CFIF>
<!---END COOKIE TEST--->
<!---TEST COOKIE VALUE TO DETERMINE DISPLAY POLL OR RESULTS--->
<CFIF #cookie.OAREIpoll# EQ 0>
<cfquery datasource="xxxxx" name="Questions">
SELECT OAREI_question.question_ID, question_text, answer_ID, answer_text, OAREI_answers.question_ID, OAREI_answers.votes
FROM OAREI_question, OAREI_answers
WHERE OAREI_question.question_ID = #SESSION.display# AND OAREI_answers.question_ID = #SESSION.display#
ORDER BY OAREI_answers.answer_ID
</cfquery>
<cfelse>
<cfif #cookie.OAREIpoll# EQ #currentpollID.poll_ID#>
<cfquery datasource="xxxxx" name="Totals">
SELECT OAREI_question.question_text, SUM(OAREI_answers.votes) AS TotalVotes
FROM OAREI_question INNER JOIN OAREI_answers
ON OAREI_question.question_ID=OAREI_answers.question_ID
WHERE OAREI_question.question_ID=#cookie.OAREIpoll#
GROUP BY OAREI_question.question_text
</cfquery>
<cfquery datasource="xxxx" name="Results">
SELECT OAREI_answers.answer_text, OAREI_answers.votes
FROM OAREI_answers
WHERE OAREI_answers.question_ID = #Cookie.OAREIpoll#
ORDER BY OAREI_answers.answer_ID
</cfquery>
</cfif>
</cfif>
The processing page form
<!---Begin RESULTS COLDFUSION--->
<cfif isDefined ('Form.QuestionID')>
<cfif IsDefined ('Form.AnswerID')>
<cfif IsDefined ("Cookie.OAREIpoll")>
<cfif #Cookie.OAREIpoll# EQ #SESSION.display#>
<br>
<div align="center">Sorry, You can only vote once.</div>
<cfabort>
</cfif>
</cfif>
<cftransaction>
<cfquery datasource="xxxxx" name="getVotes">
SELECT votes
FROM OAREI_answers
WHERE OAREI_answers.question_ID = #Form.QuestionID# and OAREI_answers.answer_ID = #Form.AnswerID#
</cfquery>
<cfset NewVotes = trim(getVotes.votes) + 1>
<cfquery datasource="xxxx" name="NewVote">
UPDATE OAREI_answers
SET votes = #NewVotes#
WHERE OAREI_answers.question_ID = #Form.QuestionID# and OAREI_answers.answer_ID = #Form.AnswerID#
</cfquery>
</cftransaction>
<!---SET COOKIE AND VALUE REMOVE--->
<cfcookie name="OAREIpoll" value="#SESSION.display#" Expires="NEVER">
<cfquery datasource="xxxxxx" name="showanswer">
SELECT *
FROM OAREI_answers
WHERE answer_ID = #Form.AnswerID#
</cfquery>
<cfquery datasource="xxxxx" name="showquestion">
SELECT *
FROM OAREI_question
WHERE question_ID = #Form.QuestionID#
</cfquery>
<cflocation url="poll.cfm">
<cfelse>
<br>
<div align="center">Sorry, you didnt select anything. Please select an answer before hitting the submit button.</div>
</cfif>
</cfif>
<cfif IsDefined ("URL.QuestionID")>
<cfquery datasource="xxxxx" name="check">
SELECT SUM(votes) AS AllVotes
FROM OAREI_answers
WHERE question_ID = #URL.question_ID#
</cfquery>
<cfif check.AllVotes is "0">
<br>
<div align="center">There are currently no votes for this poll. Vote now to be the first.</div>
</cfif>
</cfif>