Preferred way to do this is <cfif StructKeyExists(URL, 'TestValue')> On 6/27/06, Russ <[EMAIL PROTECTED]> wrote: > > Any chance that the query modusers has a field called URL? > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, June 27, 2006 4:11 PM > > To: CF-Talk > > Subject: is URL a structure, or not? > > > > Hope the answer isn't already here, but I have looked at all the > > "attempted to dereference a scalar variable" messages and haven't found > a > > solution. > > > > Moved from CF 4.5 to CF MX7. All of our code is written using the same > > methodology, using <cfif isdefined("url.testvalue")> to use values > passed > > in the URL. This code doesn't work on CF MX7 now. Quick sample code: > > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> > > <head> > > </head> > > <body> > > > > <a href="?testvalue=27">testvalue</a><br /> > > > > <cfquery datasource="General_Info" name="ModUsers"> > > Select top 5 * from GeneralPosting > > where ag_num = '303' > > </cfquery> > > > > <cfoutput> > > <cfif isdefined("url.testvalue")> > > isdefined("url.testvalue")=#url.testvalue#<br /> > > <cfelse> > > isdefined returned false for (url.testvalue)<br /> > > </cfif> > > > > <cfif StructKeyExists(url,"testvalue")> > > StructKeyExists(url,"testvalue")=#url.testvalue#<br /> > > <cfelse> > > StructKeyExists(url,"testvalue") is false<br /> > > </cfif> > > </cfoutput> > > > > Begin cfoutput loop (cfoutput query="modusers"):<br /> > > <cfoutput query="modusers"> > > > > <cfif isdefined("url.testvalue")> > > testvalue=#url.testvalue#<br /> > > <cfelse> > > isdefined returned false for (url.testvalue)<br /> > > </cfif> > > </cfoutput> > > > > outside the loop:<br /> > > > > <cfoutput> > > <cfif StructKeyExists(url,"testvalue")> > > StructKeyExists(url,"testvalue")=#url.testvalue#<br /> > > <cfelse> > > StructKeyExists(url,"testvalue") is false<br /> > > </cfif> > > </cfoutput> > > > > Begin cfoutput loop (cfoutput query="modusers"):<br /> > > <cfoutput query="modusers"> > > > > <cfif isdefined("url.testvalue")> > > testvalue=#url.testvalue#<br /> > > <cfelse> > > isdefined returned false for (url.testvalue)<br /> > > </cfif> > > <cfif StructKeyExists(url,"testvalue")> > > StructKeyExists(url,"testvalue")=#url.testvalue#<br /> > > <cfelse> > > StructKeyExists(url,"testvalue") is false<br /> > > </cfif> > > </cfoutput> > > > > outside the loop:<br /> > > > > <cfoutput> > > <cfif StructKeyExists(url,"testvalue")> > > StructKeyExists(url,"testvalue")=#url.testvalue#<br /> > > <cfelse> > > StructKeyExists(url,"testvalue") is false<br /> > > </cfif> > > </cfoutput> > > > > </body> > > </html> > > > > Output with ?testvalue=27 : > > > > testvalue > > isdefined("url.testvalue")=27 > > StructKeyExists(url,"testvalue")=27 > > Begin cfoutput loop (cfoutput query="modusers"): > > isdefined returned false for (url.testvalue) > > isdefined returned false for (url.testvalue) > > isdefined returned false for (url.testvalue) > > isdefined returned false for (url.testvalue) > > isdefined returned false for (url.testvalue) > > outside the loop: > > StructKeyExists(url,"testvalue")=27 > > Begin cfoutput loop (cfoutput query="modusers"): > > isdefined returned false for (url.testvalue) > > > > You have attempted to dereference a scalar variable of type class > > java.lang.String as a structure with members. > > > > Error occurred in line 57: > > 55 : isdefined returned false for (url.testvalue)<br /> > > 56 : </cfif> > > 57 : <cfif StructKeyExists(url,"testvalue")> > > 58 : StructKeyExists(url,"testvalue")=#url.testvalue#<br /> > > 59 : <cfelse> > > > > > > The docs for isdefined say: > > > > When working with scopes that ColdFusion exposes as structures, the > > StructKeyExists function can sometimes replace this function. The > > following lines are equivalent: > > > > if(isDefined("form.myVariable")) > > if(structKeyExists(form,"myVariable")) > > > > so I added the structKeyExists test in addition to the isdefined, and > get > > the dreaded "You have attempted to dereference a scalar variable of type > > class java.lang.String as a structure with members." error. > > > > At the top of the script, URL is obviously a structure, but within the > > <cfoutput query="modusers"> loop something happens to turn it into a > > string. > > > > What the heck is going on here? We really need a solution for this, as > we > > need to deploy a new server with CF MX7 on it and this appMUST work. > > > > > > Bill Woodland, Programmer V > > Texas Building and Procurement Commission > > Phone: 512-936-2901 Fax: 512-236-6166 Email: > > [EMAIL PROTECTED] > > > > > > > >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244905 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

