problems with strings and " in asp: how to use the the quotation mark correctly?

  • Thread starter Bart Plessers \(artabel\)
  • Start date
B

Bart Plessers \(artabel\)

Hello,
I have problems with the quotation mark and strings in my asp script.

I made a general FORM (myform.asp) to read out data from a dbase

Some vars are defined in the FORM:
SQL_DBASE
SQL_SELECT
SQL_TABLE
SQL_CONDITION

In the script, this information is glued together as a SQL expression:
SQL = "SELECT " & SQL_SELECT & " FROM " & SQL_TABLE & " WHERE " &
SQL_CONDITION & " ;"
and a table is generated from this SQL statement

However,
I want to call this form also with an external link and pars some
parameters,
example:
<a href="myform.asp?var01=string01">Mylink</a>

When this link is activated, the form myform.asp is called with querystring
var01=string01
and SQL_CONDITION becomes:
SQL_CONDITION = "MyField = '" & Request.QueryString("var01") & "'"


However
The SQL_CONDITION shows NOT up correctly in my form, it becomes
MyField =

in stead of
MyField = "string01"


The problem is that the '-character is not converted to a "-character


anybody?

any help is appreciated

bartp
 
R

Ray at

Does this line:
SQL = "SELECT " & SQL_SELECT & " FROM " & SQL_TABLE & " WHERE " &
SQL_CONDITION & " ;"

come before this line?
SQL_CONDITION = "MyField = '" & Request.QueryString("var01") & "'"



And what does this yield?
Response.Write Request.Querystring("var01")

And what do you mean about ' being converted to "?

Ray at work
 
P

Phillip Windell

Use the single Quote in all HTML Values and in the SQL Statement and
you will have a lot less trouble.

Also HTML Values don't need any quotes at all if they are single words
without and spaces, although I still always use single quotes anyway.


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
A

Adrienne

Gazing into my crystal ball I observed "Phillip Windell" <pwindell{at}
wandtv*d0t*com> writing in
Also HTML Values don't need any quotes at all if they are single words
without and spaces, although I still always use single quotes anyway.

HTML attributes need quotes if they are character values. XHTML requires
ALL attributes be quoted.
 
B

bart plessers

found the solution:

SQL_CONDITION = "Gallery = " & chr(34) & Request.QueryString("Gallery") &
chr(34)

with the chr(34) the problems were all solved.

When I used ', I had some problems running the query

Anyway, thanx for your time!

bartp

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================
 
P

Phillip Windell

I had to go verify it without "official webmaster", our resident
in-house HTML expert....she says that although most people still use
the quotes, words do not require quotes if they consist of only one
word with no spaces:

value = phil <-- is fine
value = phil windell <-- will not work
value = 'phil windell' or value = "phil windell" <-- is fine
Although most people still include quotes as either a standard
practice or just habit.


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 
P

Phillip Windell

Phillip Windell said:
I had to go verify it without "official webmaster", our resident

Stinking "typos"! should say, "...verify it with *our*...."
 
P

Phillip Windell

I don't know, I assume she does...we don't use any XHTML or XML.


--

Phillip Windell [CCNA, MVP, MCP]
(e-mail address removed)
WAND-TV (ABC Affiliate)
www.wandtv.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top