Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfquery problem

Status
Not open for further replies.

ketankshah

IS-IT--Management
Jan 11, 2001
121
IN
i have created 2 cfm pages. First one is accepting a sql statement in a form (text area) and the second page is executing the entered statement. I am getting an error while executing the statement in which I use a string value in the where criteria
(i.e. select * from module where module_name = 'TEST'). The error I get is 'Invalid syntax near 'TEST'. If I use a numeric value it works fine (i.e. select * from module where module_id = 3).
How to overcome this error ?

Please help.

I am attaching the pages.

-----------------------------------------------
The source code of the 2nd file is as follows
-----------------------------------------------
<html>
<head>
<title>SQL Execution</title>
</head>
<body>
<!---
Variables coming from a form in sql.cfm
db = database selection
select = sql statement for select query
show = column names (separated with commas) to be displayed
--->
<cfif db EQ &quot;B&quot;>
<cfquery name=&quot;sql&quot; datasource=&quot;#application.ds_service#&quot;>
#select#
</cfquery>
<cfelse>
<cfquery name=&quot;sql&quot; datasource=&quot;#application.ds#&quot;>
#select#
</cfquery>
</cfif>
<cfif show NEQ &quot;&quot;>
<cfoutput query=&quot;sql&quot;>
<cfloop index=&quot;list_elements&quot; list=&quot;#show#&quot; delimiters=&quot;,&quot;>
#Evaluate(list_elements)#&nbsp;&nbsp;&nbsp;&nbsp;
</cfloop>
<br>
</cfoutput>
</cfif>

</body>
</html>
-----------------------------------------------

Ketan
 
I think you are losing single quotes. you may have to use
preserve single quotes, urlencode functions in first page and urldecode function in the next page
 
Preservesinglequotes worked smoothly.

Thanks for the prompt reply.

Ketan



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top