> I'm trying to create a UDF as follows (it will have more
> functions later, I know it doesn't seem very useful at the moment):
>
> <cfscript>
>
> function TextStore(db_string) {
> db_string = PreserveSingleQuotes(db_string);
> return db_string;
> }
>
> <cfscript>
>
> then call it as
>
> <cfset bar = 'something'>
>
> <cfset foo = '#TextStore(bar)#'>
>
> And it keeps popping this error:
>
> "Parameter 1 of function PreserveSingleQuotes which is now
> "db_string" must be a valid variable name"
>
> Yet when I do a WriteOutput(db_string) just above the
> PSQ(db_string), it outputs the value of the variable fine.
> I've tried countless combinations of pound signs, single
> quotes, and double quotes around the PSQ function, and
> _nothing_ is working. In 5 years of working with ColdFusion
> I've never had this kind of trouble with
> PreserveSingleQuotes...what am I doing wrong here?

This is just a guess, but I think the problem might have to do with the fact
that you're using the same name for the local variable as you are for the
argument. You should be able to do this:

function TextStore(db_string) {
var tmp_db_string = PreserveSingleQuotes(db_string);
return tmp_db_string;
}

Or this:

function TextStore(db_string) {
return PreserveSingleQuotes(db_string);
}

However, as Barney points out, this isn't going to buy you much, I suspect,
since it only makes sense to use PreserveSingleQuotes within a CFQUERY tag.
Presumably, you could call your function within your CFQUERY tag and it
might work, but I don't know if that's what you plan to do.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
phone: 202-797-5496
fax: 202-797-5444
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to