Quote:
quote:Originally posted by Syster Tara
Thank you all so much for your help, especially Woody! My program now works - no more error msg!
You guys are gonna have to tutor me about single and double quotes concerning sql statements. I very much have a mental block about that, and the books don't really help much. For example, in my "insert" and "select" statements, there are single quotes next to double quotes and stuff, and I really can't make any sense out of it. It looks too messy to me. Can you enlighten me about that?
|
Certainly. The single quotes are used by SQL, and the double quotes are used by Javascript. You are building a Sql statement (that uses single quotes) using Javascript (which is using the double quotes).
In Sql, the single quotes are required to delimit a literal string value, and in Javascript the double quotes are used to delimit a literal string value. You are concatenating a string (using the + operator) out of literals (the things in double quotes) and variables. The string you are building happens to have single quotes in it since they are needed by the Sql statement to indicate literals, just like it also has letters and words.
So... what are literals??? A literal is treated differenlty than the rest of your code when processing is done. The string literal is treated merely as the "literal string" that it contians, and it isn't used to provide instructions to the processor - it is something that can be operated on, but isn't itself part of the instructions. Without having some way to indicate that the string is meant to NOT be part of the code itself, all languages use some way to delimit strings. In our case, it is the Single and Double quotes.
So, to say that all over again - the single quotes are needed by the Sql database to be able to do its work, and the double quotes are needed by Javascript to do its work.
Dang. It just seems like I am saying the same thing over and over.
Anyway - I hope that helps a little.
Woody Z
http://www.learntoprogramnow.com