1

I am trying to insert the following string in my DB using CF query: Aman#30 is "OK"

But I get the error "Invalid construct: Either argument or name is missing."

On further investigation I found that this happens only if I use # or " in the string.

Any suggestions on how to resolve this issue?

2
  • Yep. We need to see your code, because usually # signs only need to be escaped when hard coded. The behavior is different when a # sign is contained in a form field for example. Commented Jun 11, 2012 at 14:49
  • 1
    FYI - here's a pretty good article on when to use pound signs. it will help clear this up a little bit for you :) coldfusionmuse.com/index.cfm/2011/2/10/… Commented Jun 11, 2012 at 15:49

1 Answer 1

9

You'll most likely need to escape the pound-sign and the quotes. For example:

<CFSET yourstring = "Aman##30 is ""OK""" /> <CFQUERY result="qRes" datasource="#yourDSN#"> INSERT INTO `yourtable` (`yourstringfield`) VALUES (<CFQUERYPARAM value="#yourstring#" cfsqltype="cf_sql_varchar" />) </CFQUERY> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.