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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coldfusion Radio Buttons problem...

Status
Not open for further replies.

ClarkKent101

Programmer
Jul 19, 2006
48
DE
Hi Everyone,

I have a form which i use to update a MySQL database. The form contains three radio buttons which i have included, these three radio buttons need to assign one value to each of their corresponding fields in the MySQL database... in other words, each radio button is tied together to one a field in the database.

The problem i am experiencing is this error i keep getting when i submit the form, the error states the following:

"Syntax error or access violation message from server: "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 'WHERE carModelID=11' at line 147"

I checked the SQL and it looks fine to me, but just in case i'm doing something wrong (which i must be) i'll post the code that the error points to. Here are the lines of code the error displays to me...

246 : carOffline = 1
247 : </cfif>
248 : WHERE carModelID=#FORM.carModelID#
249 : </cfquery>
250 : <cflocation url="/admin/cars/index.cfm">


Line number 248 should be in Bold, that is what coldfusion is pointing out to me to be wrong. I had this working before with checkboxes but checkboxes don't serve the same purpose radio buttons do... Here is the code i implemented to assign the value of each radio button to their corresponding field in the database...(Note: The following code is the lines of code before line number 246)

, <cfif FORM.radioGroup EQ 'online'>
online = 1,
carDeleted = 0,
carOffline = 0,
<cfelseif FORM.radioGroup EQ 'carDeleted'>
online = 0,
carDeleted = 1,
carOffline = 0,
<cfelseif FORM.radioGroup EQ 'carOffline'>
online = 0,
carDeleted = 0,
carOffline = 1
</cfif>
WHERE carModelID=#FORM.carModelID#
</cfquery>

And lastly i will post the radio button input tags that correspond to the above code...

<input type="radio" name="radioGroup" value="carDeleted" <cfif (#rsCarModel.carDeleted# EQ 1)>checked</cfif>>

<input type="radio" name="radioGroup" value="carOffline" <cfif (#rsCarModel.carOffline# EQ 1)>checked</cfif>>

<input type="radio" name="radioGroup" value="online" <cfif (#rsCarModel.online# EQ 1)>checked</cfif>>

Can anybody see what i am doing wrong? I can't seem to find any syntax error but yet coldfusion keeps throwing me with that error everytime i submit the form. Any ideas?

Thank you for your time,

- CK
 
Might not be related, but your commas are way off.

<cfif FORM.radioGroup EQ 'online'>
online = 1,
carDeleted = 0,
carOffline = 0(,)
<cfelseif FORM.radioGroup EQ 'carDeleted'>
online = 0,
carDeleted = 1,
carOffline = 0(,)
<cfelseif FORM.radioGroup EQ 'carOffline'>
online = 0,
carDeleted = 0,
carOffline = 1
</cfif>
WHERE carModelID=#FORM.carModelID#
</cfquery>


The 2 commas in bold (I've put brackets around the commas so they stand out) should be removed otherwise your query will throw an error if FORM.radioGroup equals anything other than carOffline.

Hope this helps

Wullie

Fresh Look - Quality Coldfusion 7/Windows Hosting
YetiHost - Coming Soon

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Hi Wullie,

Thanks so much! That pretty much solved it. I knew i was close but i guess being new to coldfusion comes with its price ;).

Thanks once again,

- CK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top