Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quotes in database query cut string

Status
Not open for further replies.

NoWizod

Technical User
Apr 27, 2007
9
0
0
US
I am pulling information from a database which includes measurements and to show inches quotes are used. So, when I create the query and list, those Descriptions with measurements are being truncated where there are quotes. I haven't been able to find a solution. Without getting too crazy is there a way around this?
Thanks!!
 
can't help you without seeing code

start by showing us the CFQUERY and CFOUTPUT tags involved

r937.com | rudy.ca
 
Yes...that might be helpful! Sorry about that... To further clarify, I am able to print from the <cfoutput> tags, however it's being passed via the form to the form handler. I'm thinking that may be where the issue lies.

Code:
<cfquery datasource="HardwareStore" name="products">
SELECT * FROM Products
</cfquery>

<cfoutput>#Description#</cfoutput>

<input type="hidden" value="#Description#" name="Description">

Form Handler:
Code:
<cfset itemDesc = ListGetAt(#FORM.Description#,#value#)>
       <td><cfoutput>#itemDesc#</cfoutput></td>

Thanks for checking it out!
 
yup, that's your problem, any embedded " in the description will prematurely terminate the INPUT VALUE

you could do this --

<input type="hidden" value='#Description#' name="Description">

but then you'd have the same problem with any embedded '

however, since we are talking about product descriptions, what's the harm in entity-encoding the quotes?

i.e. replace " with &#8221; and ' with &#8217;




r937.com | rudy.ca
 
So, would the best way to accomplish that be to REReplace on the query strings?
Thanks!!
 
Thanks!!
Is my syntax incorrect here? It looks correct to me but is throwing me an error.
Code:
<cfset FORM.Description = Replace(#FORM.Description#,'"',&#8221,all)>
 
Thanks for your efforts. Unfortunately the strings are still being truncated. I may have to set it up differently.
Thanks again!
 
ok, i just did a small test:


when you enter stuff like 2"2' to the textfield and hit submit, the page displays the same entry. so, will it be possible that your field gets truncated because somebody enters information more than they are supposed to? i.e. the field is defined as varchar(10) and i enter 12 characters. it will truncate the last 2 chars.

hope it helps...

 
Use the HTMLEditFormat() function

<cfoutput>...
<input type="text" value="#HTMLEditFormat(Description)#" name="Description" />
</cfoutput>
 
i believe there might be wider support among obscure browsers for the numeric entity

essentially no difference in all major browsers

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top