Re: A [Loop][APPEND][URL] ... [/URL][/APPEND]/Loop] Question
This WebDNA talk-list message is from 2000
It keeps the original formatting.
numero = 31911
interpreted = N
texte = Ah ha! You have discovered the truth about the way Webcat converts[url]-ized characters back into [unurl]-ized characters when it appends orreplaces data into a database. Now we will have to kill you.Seriously, if Webcat encounters an ampersand it must know what to do withit. If the ampersand is wrapped in a [url] context, it knows that it mustbe treated as a part of a text string (even though the string & containsan ampersand itself). Without the [url] context, your append string wouldessentially look like this to Webcat:[append db=blah.db]OWNER_NAME=Andy & 1Vicky Perez[/append] ^ Problem is hereWebcat parses the variables in the append string (or replace string) usingthe ampersand and the equals sign. With that in mind, the only valid datapair in the append string above is OWNER_NAME=Andy_space_. The remainder ofthe string is ignored.Webcat then [unurl]-izes the string when writing it to the database.Who knew?Rule of thumb: wrap all data in append and replace strings in [url]contexts. It will eliminate the possibility of illegal characters breakinga data string. And since the data is stored in it's original, [unurl]-izedstate in the database, there's no reason not to (although having said that,I'm sure someone will point one out).PS. For debugging purposes, when you encounter unexpected behavior, trywriting the string as it is interpreted by Webcat. It can help you seehidden problems where they are not readily evident. For example,this string, in itself, doesn't look problematic: XX=[XX]&YY=[YY]&ZZ=[ZZ].But if [XX]=Red and [YY]=Blue and [ZZ]=Black & Blue, then[append db=blah.db]XX=Red&YY=Blue&ZZ=Black & Blue[/append] ^ Problem[search db=blah.db&eqXXdata=Red&eqYYdata=Blue&eqZZdata=Black & Blue] Problem again ^Hey, while we're at it, here's a little trick I've been using lately thatinvolves interpretation of ampersands, but in a different way. Have youever wanted to store multiple variables in a cookie and retrieve them later?Let's go a step further and encrypt the data in the cookie, making it moresecure. Since ampersands are illegal characters in cookies, we'll [url]-izethe encrypted string to eliminate the ampersand problem. Here's what youdo.[setcookie name=blah&value=[url][url][encryptseed=blah]XX=[url][XX][/url]&YY=[url][YY][/url]&ZZ=[url][ZZ][/url][/encrypt][/url][/url]]Notice the doubling of the [url] context to eliminate the ampersandscompletely. Then, to retrieve your data from the cookie, a simple multipletext variable context is used.[text multi=t][decrypt seed=blah][getcookie blah][/decrypt][/text]The ampersands are interpreted properly in the multi text context and thevalues for [XX], [YY], and [ZZ] are returned. Works like a champ and it'sfun at parties too.Enjoy,Mike> Hi All,> > I'm using WebCAT 3.0.8 in the Mac.> > > I'm entering the following text string into a database: Andy & Vicky Perez> > This text is passed via a form variable.> > Using [Convertchars] in the code below, the only thing entered into> the database would be the text Andy (without the quotes) and> everything else would be cut off.> > > I arrived at the following code after a lot of experimenting with the> [ConvertChars] tag. On a whim I threw the [URL] tag in what you see> below.> > [showif [action]=Append]> > [loop start=1&end=8&advance=1]> [Showif [Interpret][_owner[index]][/Interpret]!]> [Append > db=^capitolracing/owners/owners.db]OWNER_NAME=[URL][Interpret][_owner[index]][> /Interpret][/URL][/Append]> > [/Showif]> [/loop]> > [/showif]> > When I look at the database in a text editor the entry is: Andy &> Vicky Perez (Great, thats what I want)> Not: Andy%20%26%201Vicky%20Perez> > I'm curious though...why does this work this way?> Why doesn't the string Andy%20%26%201Vicky%20Perez get input into the> database?> > Putting this [URL][Interpret][_owner[index]][/Interpret][/URL]> outside the [Append] context but still inside the loop displays the> following: Andy%20%26%201Vicky%20Perez> > Putting this [Interpret][_owner[index]][/Interpret] outside the> [Append] context but still inside the loop displays the following:> Andy & 1Vicky Perez> > However, if I use [Interpret][_owner[index]][/Interpret] inside the> [Append] without the [URL] tags around it, the data going into the> database gets cut off at the ampersand. I double checked the docs,> but I must have missed something. Can anyone shed any light on this?> I'm glad its working the way I want, but I don't understand why.> Whenever that happens, I know something unexpected will come and> haunt me later on.> > Thanks for your time and have a great day!> > Brian> Digital Gear> > > > > > > Is there some other way I should enter ampersands into a database?-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list
.To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/
Associated Messages, from the most recent to the oldest:
Ah ha! You have discovered the truth about the way Webcat converts[url]-ized characters back into [unurl]-ized characters when it appends orreplaces data into a database. Now we will have to kill you.Seriously, if Webcat encounters an ampersand it must know what to do withit. If the ampersand is wrapped in a [url] context, it knows that it mustbe treated as a part of a text string (even though the string & containsan ampersand itself). Without the [url] context, your append string wouldessentially look like this to Webcat:[append db=blah.db]OWNER_NAME=Andy & 1Vicky Perez[/append] ^ Problem is hereWebcat parses the variables in the append string (or replace string) usingthe ampersand and the equals sign. With that in mind, the only valid datapair in the append string above is OWNER_NAME=Andy_space_. The remainder ofthe string is ignored.Webcat then [unurl]-izes the string when writing it to the database.Who knew?Rule of thumb: wrap all data in append and replace strings in [url]contexts. It will eliminate the possibility of illegal characters breakinga data string. And since the data is stored in it's original, [unurl]-izedstate in the database, there's no reason not to (although having said that,I'm sure someone will point one out).PS. For debugging purposes, when you encounter unexpected behavior, trywriting the string as it is interpreted by Webcat. It can help you seehidden problems where they are not readily evident. For example,this string, in itself, doesn't look problematic: XX=[XX]&YY=[YY]&ZZ=[ZZ].But if [XX]=Red and [YY]=Blue and [ZZ]=Black & Blue, then[append db=blah.db]XX=Red&YY=Blue&ZZ=Black & Blue[/append] ^ Problem[search db=blah.db&eqXXdata=Red&eqYYdata=Blue&eqZZdata=Black & Blue] Problem again ^Hey, while we're at it, here's a little trick I've been using lately thatinvolves interpretation of ampersands, but in a different way. Have youever wanted to store multiple variables in a cookie and retrieve them later?Let's go a step further and encrypt the data in the cookie, making it moresecure. Since ampersands are illegal characters in cookies, we'll [url]-izethe encrypted string to eliminate the ampersand problem. Here's what youdo.[setcookie name=blah&value=[url][url][encryptseed=blah]XX=[url][XX][/url]&YY=[url][YY][/url]&ZZ=[url][ZZ][/url][/encrypt][/url][/url]]Notice the doubling of the [url] context to eliminate the ampersandscompletely. Then, to retrieve your data from the cookie, a simple multipletext variable context is used.[text multi=t][decrypt seed=blah][getcookie blah][/decrypt][/text]The ampersands are interpreted properly in the multi text context and thevalues for [XX], [YY], and [ZZ] are returned. Works like a champ and it'sfun at parties too.Enjoy,Mike> Hi All,> > I'm using WebCAT 3.0.8 in the Mac.> > > I'm entering the following text string into a database: Andy & Vicky Perez> > This text is passed via a form variable.> > Using [convertchars] in the code below, the only thing entered into> the database would be the text Andy (without the quotes) and> everything else would be cut off.> > > I arrived at the following code after a lot of experimenting with the> [convertchars] tag. On a whim I threw the [url] tag in what you see> below.> > [showif [action]=Append]> > [loop start=1&end=8&advance=1]> [Showif [interpret][_owner[index]][/Interpret]!]> [Append > db=^capitolracing/owners/owners.db]OWNER_NAME=[url][interpret][_owner[index]][> /Interpret][/URL][/Append]> > [/Showif]> [/loop]> > [/showif]> > When I look at the database in a text editor the entry is: Andy &> Vicky Perez (Great, thats what I want)> Not: Andy%20%26%201Vicky%20Perez> > I'm curious though...why does this work this way?> Why doesn't the string Andy%20%26%201Vicky%20Perez get input into the> database?> > Putting this [url][interpret][_owner[index]][/Interpret][/URL]> outside the [append] context but still inside the loop displays the> following: Andy%20%26%201Vicky%20Perez> > Putting this [interpret][_owner[index]][/Interpret] outside the> [append] context but still inside the loop displays the following:> Andy & 1Vicky Perez> > However, if I use [interpret][_owner[index]][/Interpret] inside the> [append] without the [url] tags around it, the data going into the> database gets cut off at the ampersand. I double checked the docs,> but I must have missed something. Can anyone shed any light on this?> I'm glad its working the way I want, but I don't understand why.> Whenever that happens, I know something unexpected will come and> haunt me later on.> > Thanks for your time and have a great day!> > Brian> Digital Gear> > > > > > > Is there some other way I should enter ampersands into a database?-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/
Mike Davis
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
A little help on e-mail (HELP!!! :-) ) (1998)
WebCat2 several catalogs? (1997)
passing info to correct frame (2000)
Problem (1997)
access denied problem (1997)
WC2b15 File Corruption (1997)
variables in [addlineitem] (1998)
Calendar (1997)
Multiple prices (1997)
WebCatalog 2.1b4/Mac available (1997)
PIXO support (1997)
OT: Unix question (2003)
Running 2 two WebCatalog.acgi's (1996)
[searchString] (1997)
WC2b15 File Corruption (1997)
send mail problem? (1997)
Link with [cart] in db field (1999)
Again: tcpconnect problem with authorize.net (2003)
[WebDNA] SOAP support (2014)
Last digit of Credit Card Stripped (1997)