Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFUPDATE does not update

Status
Not open for further replies.

junkjones

Programmer
Jul 14, 2000
52
GB
Hi Guys - this has got to be something really stupid... but for some reason CFUPDATE is totally ignoring me and I can't figure this one out.

Here is the form:

<cfquery name=&quot;getanswers&quot; DATASOURCE=&quot;chamber&quot;>
select * from poll_answer
WHERE question_id = #pollid#
</cfquery>

<cfoutput query=&quot;getanswers&quot;>
<FORM action=&quot;votecount2.cfm&quot; METHOD=&quot;post&quot;>

#answer# <INPUT TYPE=&quot;radio&quot; NAME=&quot;id&quot; VALUE=&quot;#id#&quot;><br>
</cfoutput></p>
<INPUT TYPE=Submit VALUE=&quot;Vote!&quot;></form>

And here is the action page:

<cfquery name=&quot;addone&quot; DATASOURCE=&quot;chamber&quot;>
select * from poll_answer
where id = #id#
</cfquery>

<cfoutput query=&quot;addone&quot;>
<cfset newcount=#count#+1><br>
</cfoutput>

<cfset count=#newcount#>


<CFUPDATE DATASOURCE=&quot;chamber&quot; TABLENAME=&quot;poll_answer&quot;>

<cfoutput query=&quot;addone&quot;>#id# #question_id# #answer# #count#<BR></cfoutput>

Basically what I am doing is pulling answers out of a database to a question, based on their question_id matching the id of the question. The answers will display with a radio button next to them, which you can click and submit your vote. All I want to do is add 1 to the count value of that answer. I've FINALLY gotten this to the point where i'm not getting an error message, but now the cfupdate just doesn't seem to add the new value of the count. Any ideas?

Thanks!
 
The cfupdate works in conjunction with a submitted form only. When you call it, it looks to see what form fields were submitted, finds the primary key field (id in your case) and then updates that record with the fields that have been submitted. In your case, you're submitting only one variable, ID, so cfupdate doesn't really do anything because there are no fields passed to update. The problem in your case is that cfupdate will ignore everything you've done and just look for the submitted form fields.

To make this work, you'll need to update the database manually with a regular sql statement. I believe this will work for you.

<cfquery name=&quot;upd&quot; DATASOURCE=&quot;chamber&quot;>
update poll_answer
set count = #newCount#
where id = #id#
</cfquery>

Let me know if you have any problems,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top