Hi, Throw a <cfabort> in just above your closing </cfquery> tag. This is a neat little trick that causes CF to display the output of the 'evaluated' code inside your <cfquery> (meaning it will show you exactly what is getting sent to the database). This will show you what is getting sent. Check to see if there are any extra spaces or something in the single quotes. Copy and paste the SQL displayed on the screen into your query software for your database and see what result you get.
There are some other suggestions I have for you: 1. You only need pound signs around a variable or function if you are outputting it to the screen or it's inside quotes (like inside of a <cfquery> for example). In other words this: <cfset rawprofilename = #left(#URL.Profile#,30)#> Can actually just be this: <cfset rawprofilename = left(URL.Profile,30) > Also, you don't need a <cfoutput> inside of any CF tags or functions. So this: <cfset profilename = "<cfoutput>#left(rawprofilename,(space -1))#</cfoutput>"> Should be this: <cfset profilename = left(rawprofilename,(space -1)) > Or this: <cfset profilename = "#left(rawprofilename,(space -1))#" > Either one would work, but the first one is fastest. If you find extra spaces in your profilename variable, simply throw a 'trim' around it in your cfquery: SELECT * FROM cohvclub WHERE cohvuser = '#trim(profilename)#' Lastly, you should use <cfqueryparam> wherever possible, so your query should actually be something like this: SELECT * FROM cohvclub WHERE cohvuser = <cfqueryparam value="#trim(profilename)#" cfsqltype="cf_sql_varchar"> (or whatever type it is) Hope this all helps! Dave Phillips -----Original Message----- From: Rick Cummings [mailto:[email protected]] Sent: Saturday, November 07, 2009 10:22 PM To: cf-newbie Subject: variables problem Thanks for the previous help :) Still following from the previous question, what I want to do is be able to call one page which displays the info from a specific profile. That is to say, click on a member's name, and a page comes up displaying the information for the member, not a page that is member-specific. Clicking on any member name calls findmemberpage.cfm populated with data for foo rather than going to a member-specific page such as foo.cfm I have coded around this problem twice, but it still gets back to the same issue... variables. The first page has the following code. Yes, the @ sign is there for reasons you will see in the page resulting when the user clicks on any of the member buttons displayed. <cfset profile= "#getMembers.firstname# #getMembers.lastname#@"> <a href= "../profiles/findmemberprofile.cfm?Profile=<cfoutput>#getMembers.firstname# #getMembers.lastname#@</cfoutput>"> <input type = "submit" value="#getMembers.firstname# #getMembers.lastname#" Clicking on any button from the Members Page brings you to the following: The test code on the resulting findmembersprofile page is checking for the clicked on member name, and the cfoutput tags are there to see what is happening. When clicking on any given member name, the resulting URL.Profile starts with the member name clicked on, but then also includes all the following member names. To distinguish where one member name ends and the next begins, the @ sign is being used as a divider. Members names are never longer than 30 characters. <cfset rawprofilename = #left(#URL.Profile#,30)#> <cfoutput> #rawprofilename# </cfoutput> <cfset space=#find("@",'#rawprofilename#',0)#> <cfoutput> Character found at #space# </cfoutput> <cfset profilename = "<cfoutput>#left(rawprofilename,(space -1))#</cfoutput>"> <cfoutput> Profile to find is #profilename#. </cfoutput> So far, no problem... the clicked on members name is properly displayed from the #profilename# variable. Now, the following code never displays the user name or the profile status... I have put # signs, single quotes, double quotes, varying combinations and nothing around the variable profilename but I either get CFM error messages or nothing displayed. If I replace '#profilename#' with "foo" it works, but clicking on the profile for foo on the first (calling) page never displays the information. <cfquery name="gotProfile" datasource="cohv"> SELECT * FROM cohvclub WHERE cohvuser = '#profilename#' </cfquery> <cfoutput query= "gotProfile" > Member #gotProfile.cohvuser# Profile Status #gotProfile.profile# </cfoutput> Thanks again for your assistance. Viajero. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4891 Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
