View Single Post
  #1 (permalink)  
Old Sep 17th, 2003, 13:50
jakyra jakyra is offline
Reputable Member
Join Date: Sep 2003
Location: USA
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Freakish ASP quote handling

I've got this part of my site where people enter information into a textbox.

I learned long ago (and far away ) that with ASP you need to replace ' with '' and " with "" or it choaks because it thinks it's a string terminater.

I've got a function that does this (and other things) for me...

Code: Select all
function switchQuotes(text)
	while instr(text, "  ") > 0
		text = Replace(text, "  ", " ")
	wend
	text =  Replace( _
		Replace( _
		Replace( _
		Replace( _
		Replace( _
		Replace( Trim(text), "'", "''"), _
				    "\n", " "), _
				    vbcrlf, " "), _
				    "|", ""), _
				    "%", ""), _
				    chr(34), """")
'	response.write "switchme!"
	switchQuotes = text		
end function
My problem is that *sometimes* this backfires. It only seems to happen during the editing of the text. But this review works fine:
This book is the follow-up to Surely You're Joking, Mr. Feynman: Adventures of a Curious Character and I recommend that it should be read only after reading that volume. The book is organized as a series of loosely related chapters that illustrate Feynman's unique perspective and his ways of interacting with the world. It is less personal than the preceding book in that some of the chapters are more about science-related topics and less about Feynman. Some of the chapters fill in details that were introduced in "Surely You're Joking"

but this one doesn't:
The comments of "A Reader" below obviously mean that the book is truthful and spot on. Otherwise, why would he get so upset! I enjoyed this book and find it scary that so many people get their news from these liars. It's not possible for everyone in America to confirm facts that the media spit out. America should demand truth in journalism. Whether you are right or left, at least you want to know the truth, dont you? Thank you Al Franken.

If I edit the second review by adding "Testing 1,2" to the end, that part is not added and It's looks like It''s.

When I display the SQL to the page, it's correct:
UPDATE TblReviews SET Title='Lies and the Lying Liars Who Tell Them: A Fair and Balanced Look at the Right', Author='Al Franken', Illustrator='', LevelID=5, Genre='Biography', Culture=134, Review='The comments of "A Reader" below obviously mean that the book is truthful and spot on. Otherwise, why would he get so upset! I enjoyed this book and find it scary that so many people get their news from these liars. It''s not possible for everyone in America to confirm facts that the media spit out. America should demand truth in journalism. Whether you are right or left, at least you want to know the truth, dont you? Thank you Al Franken. Testing 1,2' WHERE ISBN='0-525-94764-7' AND Reviewer=1852

But what I get on my display page is wrong:
The comments of "A Reader" below obviously mean that the book is truthful and spot on. Otherwise, why would he get so upset! I enjoyed this book and find it scary that so many people get their news from these liars. It''s not possible for everyone in America to confirm facts that the media spit out. America should demand truth in journalism. Whether you are right or left, at least you want to know the truth, dont you? Thank you Al Franken.

AAAAAAAAAAAAAAAAAAAAAAAARG!

This seems to be a bug sort of thing, but I have no idea how to work around this..

Does anyone know?

Thanks
jakyra