Enjoy an ad free experience by logging in. Not a member yet?
Register .
04-29-2009, 06:22 PM
PM User |
#1
New Coder
Join Date: Jul 2008
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Syntax error (missing operator) in query expression
I'm getting this error and I can't work out why!
Code:
<cfquery name="insertart" datasource="062105cs06sr">
INSERT INTO art (userid, artcat, arttitle, arturl, artdescription, artdatecreated, artkeyword)
values (#form.userid#, #form.artcat#, #form.arttitle#, #form.arturl#, #form.artdescription#, #form.artdatecreated#, #form.artkeyword#)
</cfquery>
This is a form to put an image into the database and add some information about it.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'http://newmedia.leeds.ac.uk/ug06/cs06sr/cf/images/suzierthanyoulabel.png'.
The error occurred in F:\wwwroot\ug06\cs06sr\cf\image-uploaded.cfm: line 13
11 : <cfquery name="insertart" datasource="062105cs06sr">
12 : INSERT INTO art (userid, artcat, arttitle, arturl, artdescription, artdatecreated, artkeyword)
13 : values (#form.userid#, #form.artcat#, #form.arttitle#, #form.arturl#, #form.artdescription#, #form.artdatecreated#, #form.artkeyword#)
14 : </cfquery>
15 : Record Inserted!
Hmmmm!
04-30-2009, 07:19 AM
PM User |
#2
Regular Coder
Join Date: Feb 2009
Location: NJ, USA
Posts: 476
Thanks: 2
Thanked 70 Times in 69 Posts
Again, not a ColdFusion issue per se, but another database issue. The reason you're getting this error is because when inserting a value into a text field in the database, you need to surround the actual text to be inserted with single quotes. Your code should look like the following (which I have reformatted for clarity's sake):
Code:
<cfquery name="insertart" datasource="062105cs06sr">
INSERT INTO art (
userid,
artcat,
arttitle,
arturl,
artdescription,
artdatecreated,
artkeyword
) VALUES (
#form.userid#,
'#form.artcat#',
'#form.arttitle#',
'#form.arturl#',
'#form.artdescription#',
'#form.artdatecreated#',
'#form.artkeyword#'
)
</cfquery>
Note that I did not surround the userID field's value with single quotes, because it is (or at least should be) a number field. Only values for text fields must be surrounded by single quotes.
Hope that helps.
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 06:28 PM .
Advertisement
Log in to turn off these ads.