What's wrong?

O

Oli

Hi

URL in address bar:
http://localhost/edituser.asp?pID=1

SQLQuery = "SELECT * from Applicant WHERE pID="' & Request.Querysting('pID')
& '"

But it only gets: SELECT * from Applicant WHERE pID=

This is only simple but is causing me a headache!

Any ideas??
TIA - Oli
 
S

stewert gallington

You've miss spelt querystring as querysting.

To avoid this problem you can just refer to it like:

request('pID')

Its also handy because you can use it to locate a variable anywhere, be it
in the querystring or on a form thats submitted.
 
B

Bob Barrows

Oli said:
Hi

URL in address bar:
http://localhost/edituser.asp?pID=1

SQLQuery = "SELECT * from Applicant WHERE pID="' &
Request.Querysting('pID') & '"

But it only gets: SELECT * from Applicant WHERE pID=

This is only simple but is causing me a headache!

Any ideas??
TIA - Oli

Nope. Show us some more of the script. Actually, you should create a test
page with just the following code in it:

<%
dim parm
parm = Request.Querystring("pID")
Response.Write "parm contains " & parm
Response.End
%>

Run the page, adding the querystring to the url, and let us know if you
don't get the intended result. If you do get the intended result, start
adding code from your current page until it stops working. If that does not
clue you into the problem, show us the code that breaks the page.

Bob Barrows
 
B

Bob Barrows

stewert said:
You've miss spelt querystring as querysting.

Good eye! I missed that. (obviously)
To avoid this problem you can just refer to it like:

request('pID')

Its also handy because you can use it to locate a variable anywhere,
be it in the querystring or on a form thats submitted.

But it can also cause problems:
1) Performance is impacted because several collections (including the
servervariables collection - a real performance hit) may have to be searched
to find the requested variable
2) You may get the wrong value if your variable name matches one of the
variable names in another collection. Try getting the result of
http://...?url=test by using request("url")

Our recommendation is to always specify the collection you wish to retrieve
the variable value from.

Bob Barrows
 
T

Tom B

In addition to the other comments, I've always used quotes around the item.
You have apostrophes. I'm not sure if it makes a difference, I've never
tried.
 
A

Aaron Bertrand - MVP

In addition to the other comments, I've always used quotes around the
item.
You have apostrophes. I'm not sure if it makes a difference, I've never
tried.

Yes, you should get:

Microsoft VBScript compilation error '800a03ea'
Syntax error

In any case, the reason Oli is getting a blank querystring is because the
delimiters are all jumbled (spaces added for legibility). The first ' acts
as a comment, so the rest of the line (after pID=) is ignored.

"... WHERE pID= " ' & Request.Querysting('pID') & ' "

Should be (note the differences in quotes and apostrophes):

"... WHERE pID= ' " & Request.Querysting("pID") & " ' "
 
T

TomB

If I had copied it into my editor, it would have turned green and I would
have noticed that.

Good eye Aaron.
 
L

Lakshmi Narayanan

Dear sir,
correct the sqlquery as follows
1). single qoute should come within double qoute
2). As an expert said spelling mistake in Querystring

SQLQuery = "SELECT * from Applicant WHERE pID='" &
Request.Querystring('pID') &"'"

or

SQLQuery = "SELECT * from Applicant WHERE pID=" &
Request.Querystring('pID')


I hope this will work.
 

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

Staff online

Members online

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top