954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

<cfquery> Error

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>
zoid777
Newbie Poster
16 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

Hello Zoid,

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

Matt

mbogdanovich
Newbie Poster
1 post since Jan 2008
Reputation Points: 10
Solved Threads: 1
 

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

zoid777
Newbie Poster
16 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

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.

zoid777
Newbie Poster
16 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

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

zoid777
Newbie Poster
16 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

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 Ridd
Junior Poster in Training
52 posts since Nov 2007
Reputation Points: 13
Solved Threads: 9
 

Nige thanks for your help, you where very helpful.

zoid777
Newbie Poster
16 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You