|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
CFQuery QuestionsHi All,
Getting more knowledge of CF. I have questions on CFQuery and URL Parameters. Is the following code right: <!---give a default value to avoid error---> <cfparam name="URL.queryName" default=""> <!---scope out if it is not null---> <cfif isdefined("URL.queryName") and #URL.queryName# NEQ ""> <!--- Query the Content table from MySQL to get the content we are to display ---> <CFSET theSQL="SELECT queryName, title, content FROM content WHERE queryName = " #URL.queryName# > <cfquery name="getContent" datasource="#application.dsn#">#theSQL# </cfquery> <!--- for testing only ---> <CFOUTPUT>#theSQL#</CFOUTPUT> <cfif getContent.recordCount EQ 1> <!--- we have records ---> <cfoutput query="getContent"> #content# </cfoutput> <cfelse> <!--- we dont have any data so error ---> NO DATA </cfif> </cfif> I get CF Construct errors and I know it is due to the CFSet statement, but I don¹t see how to do it correct. Advice? -Jason ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-mac/message.cfm/messageid:5641 Subscription: http://www.houseoffusion.com/groups/cf-mac/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.48 |
|
|
Re: CFQuery QuestionsImmediate error I see:
> <CFSET theSQL="SELECT queryName, title, content FROM content WHERE > queryName = " #URL.queryName# > Should be > <CFSET theSQL="SELECT queryName, title, content FROM content WHERE > queryName = '#URL.queryName#' " > But once you have that working, check out the ColdFusion docs on cfqueryparam or you're gonna get hacked. Google "sql injection attack". Best Wishes, Peter On Jan 9, 2009, at 5:55 PM, J. Todd Slack-Moehrle wrote: > Hi All, > > Getting more knowledge of CF. > > I have questions on CFQuery and URL Parameters. > > Is the following code right: > > <!---give a default value to avoid error---> > <cfparam name="URL.queryName" default=""> > > <!---scope out if it is not null---> > <cfif isdefined("URL.queryName") and #URL.queryName# NEQ ""> > > <!--- Query the Content table from MySQL to get the content we > are to > display ---> > > <CFSET theSQL="SELECT queryName, title, content FROM content WHERE > queryName = " #URL.queryName# > > > <cfquery name="getContent" datasource="#application.dsn#">#theSQL# > </cfquery> > > <!--- for testing only ---> > <CFOUTPUT>#theSQL#</CFOUTPUT> > > > <cfif getContent.recordCount EQ 1> > <!--- we have records ---> > > <cfoutput query="getContent"> > #content# > </cfoutput> > <cfelse> > <!--- we dont have any data so error ---> > NO DATA > </cfif> > > </cfif> > > I get CF Construct errors and I know it is due to the CFSet > statement, but I > don¹t see how to do it correct. > > Advice? > > -Jason > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-mac/message.cfm/messageid:5642 Subscription: http://www.houseoffusion.com/groups/cf-mac/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.48 |
|
|
Re: CFQuery QuestionsOh, and you might want to choose cf talk for these questions - this
list is for questions relating to Mac computers and CF On Jan 9, 2009, at 5:55 PM, J. Todd Slack-Moehrle wrote: > Hi All, > > Getting more knowledge of CF. > > I have questions on CFQuery and URL Parameters. > > Is the following code right: > > <!---give a default value to avoid error---> > <cfparam name="URL.queryName" default=""> > > <!---scope out if it is not null---> > <cfif isdefined("URL.queryName") and #URL.queryName# NEQ ""> > > <!--- Query the Content table from MySQL to get the content we > are to > display ---> > > <CFSET theSQL="SELECT queryName, title, content FROM content WHERE > queryName = " #URL.queryName# > > > <cfquery name="getContent" datasource="#application.dsn#">#theSQL# > </cfquery> > > <!--- for testing only ---> > <CFOUTPUT>#theSQL#</CFOUTPUT> > > > <cfif getContent.recordCount EQ 1> > <!--- we have records ---> > > <cfoutput query="getContent"> > #content# > </cfoutput> > <cfelse> > <!--- we dont have any data so error ---> > NO DATA > </cfif> > > </cfif> > > I get CF Construct errors and I know it is due to the CFSet > statement, but I > don¹t see how to do it correct. > > Advice? > > -Jason > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-mac/message.cfm/messageid:5643 Subscription: http://www.houseoffusion.com/groups/cf-mac/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.48 |
|
|
Re: CFQuery QuestionsThanks for the advice Peter. I appreciate it.
-Jason On 1/9/09 3:00 PM, "Peter Bell" <pbell@...> wrote: > Oh, and you might want to choose cf talk for these questions - this > list is for questions relating to Mac computers and CF > > On Jan 9, 2009, at 5:55 PM, J. Todd Slack-Moehrle wrote: > >> Hi All, >> >> Getting more knowledge of CF. >> >> I have questions on CFQuery and URL Parameters. >> >> Is the following code right: >> >> <!---give a default value to avoid error---> >> <cfparam name="URL.queryName" default=""> >> >> <!---scope out if it is not null---> >> <cfif isdefined("URL.queryName") and #URL.queryName# NEQ ""> >> >> <!--- Query the Content table from MySQL to get the content we >> are to >> display ---> >> >> <CFSET theSQL="SELECT queryName, title, content FROM content WHERE >> queryName = " #URL.queryName# > >> >> <cfquery name="getContent" datasource="#application.dsn#">#theSQL# >> </cfquery> >> >> <!--- for testing only ---> >> <CFOUTPUT>#theSQL#</CFOUTPUT> >> >> >> <cfif getContent.recordCount EQ 1> >> <!--- we have records ---> >> >> <cfoutput query="getContent"> >> #content# >> </cfoutput> >> <cfelse> >> <!--- we dont have any data so error ---> >> NO DATA >> </cfif> >> >> </cfif> >> >> I get CF Construct errors and I know it is due to the CFSet >> statement, but I >> don¹t see how to do it correct. >> >> Advice? >> >> -Jason >> >> >> >> >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-mac/message.cfm/messageid:5644 Subscription: http://www.houseoffusion.com/groups/cf-mac/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.48 |
| Free embeddable forum powered by Nabble | Forum Help |