Hello Friends I ran into a syntax error updating a form, I have added a comment to the line below, Please could anyone tell me what I did wrong!!!!

<cfquery name="update student" datasource="#Request.super#">
UPDATE student
SET
studentfirstname='#Trim(Form.studentfirstname)#',.
studentlastname='#Trim(Form.studentlastname)#',.
address='#Trim(Form.address)#',.
city='#Trim(Form.city)#',.
state='#Trim(Form.state)#',.
studentage='#Trim(Form.studentage)#',.
studentclass='#Trim(Form.studentclass)#',.
studentstartdate='#Trim(Form.studentstartdate)#',.
studentgraduationdate='#Trim(Form.studentgraduationdate)#',.
comments=
<cfif Len(Trim(Form.comments)) GT 0>
'#Trim(Form.comments)#'
<cfelse>
NULL
</cfif>
WHERE
studentlastname = #Trim(Form.oldstudent)#,(THIS IS WHERE THE ERROR IS)
</cfquery>
<cflocation url="Finished.cfm?msg=#URLEncodedFormat('#Form.studentlastname# has been updated in the database.')#">
<html>
<head>
<title>studenteditaction page</title>
</head>

<body>
</body>
</html>

Hello Zoid,

You might try single qoutes in around your variable. Hopefully that will do it.

Matt

Hello Zoid,

You might try single qoutes in around your variable. Hopefully that will do it.

Matt

Hi Matt, thanks for the post. I tried single quotes but it still gave the same error

Still need help!!!!
I am using a single table with Mysql 5.0.45 and it says check syntax error.
is this a bug or I am using the wrong syntax.

I found the solution it was the dots behind my declaration.:)

Erm can I make a suggestion that you look at using cfqueryparam as well, if anyone ever put a ' in any of the fields on the screen they can then do some nasty SQL injection into your code.
Nige
( See many references on the web about SQL Injection inculding http://msdn.microsoft.com/msdnmag/issues/04/09/SQLInjection/ )

Nige thanks for your help, you where very helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.