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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with double quotes "

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I was entering data via a form into the database. I couldn't use apostrophes because everything after the apostrophe was chopped off. I got a bit of code to sort that out but now I can't add " into any of the form fields as everything after the " is chopped off. Any ideas how the code below can be modified to sort this out?

Many thanks

James

' now we'll set up the form for submitting to the database
response.write &quot;<tr><td colspan=2>&quot;
response.write &quot;<p><br><form method='post' action='add.asp'>&quot;
For each road in request.form
If road=&quot;Flag&quot; then
response.write &quot;<input type='hidden' name='&quot;
response.write road & &quot;' value=2>&quot;
Else
response.write &quot;<input type='hidden' name='&quot;
response.write road & &quot;' value=&quot; & chr(34)
response.write request.form(road) & chr(34)
response.write &quot;'>&quot;
End If
Next
' now give the user the buttons to click on
' note the Modify button uses a snippet of javascript
response.write &quot;<input type='submit' value='Submit Information'>&quot;
response.write &quot;  &quot;
response.write &quot;<input type='button' value='Modify Information' onclick=history.go(-1)>&quot;
response.write &quot;</form></td></tr></table>&quot;
response.end
End If
Case 2
' this is where the information finally gets submitted to the database
road = request.form(&quot;road&quot;)
area = request.form(&quot;area&quot;)
postcode = request.form(&quot;postcode&quot;)
weekly_rental = request.form(&quot;weekly_rental&quot;)
number_bedrooms = request.form(&quot;number_bedrooms&quot;)
location = request.form(&quot;location&quot;)
furnished = request.form(&quot;furnished&quot;)
list_text = request.form(&quot;list_text&quot;)
detail_text = request.form(&quot;detail_text&quot;)
imageone = request.form(&quot;imageone&quot;)
imagetwo = request.form(&quot;imagetwo&quot;)

Function QS(strIn)
QS = Replace(Trim(strIn & &quot;&quot;), &quot;'&quot;, &quot;''&quot;)
If Len(QS) = 0 Then
QS = &quot;Null&quot;
Else
QS = &quot;'&quot; & QS & &quot;'&quot;
End If
End Function

set conn = server.createobject(&quot;adodb.connection&quot;)

conn.open &quot;property&quot;
SQLstmt = &quot;INSERT INTO details &quot; & _
&quot;(road,area,postcode,weekly_rental,&quot; & _
&quot;number_bedrooms,location,furnished,&quot; & _
&quot;list_text,detail_text,imageone,imagetwo) &quot; & _
&quot;VALUES (&quot; & _
QS(road) & &quot;,&quot; & _
QS(area) & &quot;,&quot; & _
QS(postcode) & &quot;,&quot; & _
QS(weekly_rental) & &quot;,&quot; & _
QS(number_bedrooms) & &quot;,&quot; & _
QS(location) & &quot;,&quot; & _
QS(furnished) & &quot;,&quot; & _
QS(list_text) & &quot;,&quot; & _
QS(detail_text) & &quot;,&quot; & _
QS(imageone) & &quot;,&quot; & _
QS(imagetwo) & &quot;)&quot;

Set RS = conn.execute(SQLstmt)
 
Function QS(strIn)
1.QS = Replace(Trim(strIn & &quot;&quot;), &quot;'&quot;, &quot;''&quot;) -- what is this [red]& &quot;&quot;[/red] used for? Shouldn't it be just Trim(strIn) ?
If Len(QS) = 0 Then
QS = &quot;Null&quot;
Else
2.QS = &quot;'&quot; & QS & &quot;'&quot; -- You're trying to format whatever QS function returns to use it in Values clause, but I'd rather do it as follows:
Values('&quot; & QS(road)& &quot;', &quot; and so on
End If
End Function
 
if you want to add quotatioons

use

tempquotes= chr(34)

tempstring=&quot;hello, my name is &quot; & tempquotes & &quot;brad&quot; & tempquotes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top