#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    1
    Rep Power
    0

    Exclamation # and url String


    I am building a url for a cfm page with a tool that gets info from a DB. The link appear in regular HTML. It populates a form that is on a cfm page. The data in the db address field sometimes contains # symbols e.g. 1000 Main Street #101. This make Cold Fusion Freak-Out (makes me freak-out as well) by passing this in as a url string. How can this be fixed? Need help today. Thanks.

    This is the current code:


    <cfif NOT IsDefined("url.a1")> <cfset #url.a1# = ""> </cfif>

    <input type="text" name="address" size="40" <cfif#a1# NEQ "">value=<cfoutput>#a1#</cfoutput></cfif>>
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,269
    Rep Power
    968
    Try using the urlEncodedFormat() function when you output your query data into the URL string.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    5
    Rep Power
    0
    This shouldnt matter

    If ColdFusion is dealing with data that is alread in a variable, like data coming form a database, the ColdFusion will escape the chars automatically

    so if you had myDomain.com/index.cfm?someVal=#hiThere, ColdFusion wont spit it cause its not having to deal with it directly. The only time ColdFusion will die is if you try something like this

    Code:
    <cfset myVar = "Hello there. I am #1">
    <cfoutput>#myVar#</cfoutput>
    If your doing stuff like that you have to escape the pounds like so

    Code:
    <cfset myVar = "Hello there. I am ##1">
    <cfoutput>#myVar#</cfoutput>
    Steve

IMN logo majestic logo threadwatch logo seochat tools logo