2 Replies Latest reply on Feb 10, 2009 7:17 PM by Tones411

    Insert a page of code into db with quotes

    DettCom
      Hello,

      I am hitting a webservice that replies with a ton of information based on a VIN. However, there is a fee everytime I do it so I would like to store this code into a database. What I would like to do is set all of the code to a variable using cfset and then insert into a database. However, I would also like to insert the populated variable (Ford), not the variable representation (#vehicleinfo.make#). I assume that I should be using the evaluate function for each variable???

      The code is attached...


      So the code is breaking where I encounter the first quote in this line: onClick="document.getElementById('options').style.display =''"


      Can someone help??? Thanks
        • 1. Insert a page of code into db with quotes
          Dan Bracuk Level 5
          quote:

          Originally posted by: DettCom
          Hello,

          I am hitting a webservice that replies with a ton of information based on a VIN. However, there is a fee everytime I do it so I would like to store this code into a database. What I would like to do is set all of the code to a variable using cfset and then insert into a database. However, I would also like to insert the populated variable (Ford), not the variable representation (#vehicleinfo.make#). I assume that I should be using the evaluate function for each variable???



          Can someone help??? Thanks

          Depending on what code you are getting, and what you want to store, you might want to check out cfsavecontent instead of cfset. If quotes are causing you a problem, that should sort itself out if you use cfqueryparam.
          • 2. Re: Insert a page of code into db with quotes
            Tones411
            I was thinking along the same lines ad DettCom.

            > 1. Use cfsavecontent to save your large text data. Example below.

            <cfsavecontent variable="VinCode">
            <cfoutput>
            ...
            ... Your VIN code here.
            ...
            </cfoutput>
            </cfsavecontent>

            > 2. In your query, use cfqueryparam. Example below.

            <cfquery name="qInsert" datasource="mydsn">
            INSERT INTO
            Vins(Vin, VinCode)
            VALUES(<cfqueryparam value="#URL.VIN#" cfsqltype="CF_SQL_VARCHAR">, <cfqueryparam value="#URL.VIN#" cfsqltype="#VinCode#">
            </cfquery>