Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Getting Started / November 2007



Tip: Looking for answers? Try searching our database.

Syntax Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cml7u - 28 Nov 2007 20:34 GMT
I have spent all day working on this ridiculously simple syntax error.

First, a couple of remarks

-The name of my cfform is surveyFORM
-the Comments section is a cftextarea
-I've set cfparams for all fields so the default runs blank.
-I've changed the fieldnames so that I would use a reserved word
-I've tried  surveyFORM.Comments; FORM.Comments; Comments  all within the '#  
#')
-When I do a dump of FORM, I get all of the information that I put in.....
-When I do a dump of surveyFORM, i get the " Variable SURVEYFORM is undefined."
-nothing is being inserted into the database, although it does show in the
dump.

any advice??

Error Executing Database Query.
Syntax error in INSERT INTO statement.
 
The error occurred in C:\ColdFusion8\wwwroot\CourseEvaluations\action.cfm:
line 140

138 : '#surveyFORM.Question21#',
139 : '#surveyFORM.Question22#',
140 : '#FORM.Blurb#')
141 : </cfquery>
142 : </cfif>
cf_dev2 - 28 Nov 2007 20:47 GMT
Its difficult to determine the error without seeing the full query.

The name of your form does not matter.  When using method="post" the variables
are always submitted in the FORM scope.  So you should use

#FORM.theFormFieldName#

.. not  ..

#NameOfYourForm.theFormFieldName#

When using method="get" the variables are submitted in the URL scope.
cml7u - 28 Nov 2007 21:16 GMT
Here is the full query

<cfquery name="insertrecord" datasource="studentsurvey">
INSERT INTO Results(StudentID,
CUM_GPA,
DateModified,
TimeModified,
INDEX,
FACULTY_ID,
Gender,
Classification,
GPA,
Reason4Course,
NumOfStudents,
Question1,
Question2,
Question3,
Question4,
Question5,
Question6,
Question7,
Question8,
Question9,
Question10,
Question11,
Question12,
Question13,
Question14,
Question15,
Question16,
Question17,
Question18,
Question19,
Question20,
Question21,
Question22,
Blurb)

VALUES ('#StudentID#', #CUM_GPA#,
'#DateModified#',
'#TimeModified#',
'#INDEX#',
'#FACULTY_ID#',
'#surveyFORM.Gender#',
'#surveyFORM.Classification#',
'#surveyFORM.GPA#',
'#surveyFORM.Reason4Course#',
'#surveyFORM.NumOfStudents#',
'#surveyFORM.Question1#',
'#surveyFORM.Question2#',
'#surveyFORM.Question3#',
'#surveyFORM.Question4#',
'#surveyFORM.Question5#',
'#surveyFORM.Question6#',
'#surveyFORM.Question7#',
'#surveyFORM.Question8#',
'#surveyFORM.Question9#',
'#surveyFORM.Question10#',
'#surveyFORM.Question11#',
'#surveyFORM.Question12#',
'#surveyFORM.Question13#',
'#surveyFORM.Question14#',
'#surveyFORM.Question15#',
'#surveyFORM.Question16#',
'#surveyFORM.Question17#',
'#surveyFORM.Question18#',
'#surveyFORM.Question19#',  
'#surveyFORM.Question20#',
'#surveyFORM.Question21#',
'#surveyFORM.Question22#',
'#FORM.Comments#')
</cfquery>
cf_dev2 - 28 Nov 2007 21:19 GMT
> #surveyFORM....

You didn't fix the FORM scope in most of the variables.

Its also possible you're using some reserved words.  They're often db specific
but "INDEX" is common reserved word.   Try changing the column name
(recommended) . If you cannot change it, try escaping it.  The syntax is db
specific.
cf_dev2 - 28 Nov 2007 21:23 GMT
> Question1,
> Question2,
...

Nothing to do with your current error, but when you see column names like
Question1,....QuestionN its usually an indicator that you need to normalize
your db.  

http://en.wikipedia.org/wiki/Database_normalization
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.