What's wrong?

Discussion in 'ASP General' started by Oli, Dec 5, 2003.

  1. Oli

    Oli Guest

    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
     
    Oli, Dec 5, 2003
    #1
    1. Advertising

  2. 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.

    "Oli" <> wrote in message
    news:bqpp0l$1p4$...
    > 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
    >
    >
     
    stewert gallington, Dec 5, 2003
    #2
    1. Advertising

  3. Oli

    Bob Barrows Guest

    Oli wrote:
    > 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
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Dec 5, 2003
    #3
  4. Oli

    Bob Barrows Guest

    stewert gallington wrote:
    > You've miss spelt querystring as querysting.


    Good eye! I missed that. (obviously)
    <grin> Of course, you realize that you misspelt "misspelt" ... ;-)

    >
    > 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
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Dec 5, 2003
    #4
  5. Oli

    Tom B Guest

    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.



    "Oli" <> wrote in message
    news:bqpp0l$1p4$...
    > 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
    >
    >
     
    Tom B, Dec 5, 2003
    #5
  6. > 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") & " ' "


    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/
     
    Aaron Bertrand - MVP, Dec 5, 2003
    #6
  7. Oli

    TomB Guest

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

    Good eye Aaron.

    "Aaron Bertrand - MVP" <> wrote in message
    news:...
    > > 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") & " ' "
    >
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > http://www.aspfaq.com/
    >
    >
    >
     
    TomB, Dec 5, 2003
    #7
  8. 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.

    >-----Original Message-----
    >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
    >
    >
    >.
    >
     
    Lakshmi Narayanan, Dec 6, 2003
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Salisha Khan
    Replies:
    1
    Views:
    11,672
    JohnFol
    Aug 1, 2003
  2. Replies:
    2
    Views:
    397
  3. Pial
    Replies:
    4
    Views:
    56,864
    Phatman
    Aug 27, 2010
  4. Paul Leventis

    Re: Quartus bug or wrong VHDL?

    Paul Leventis, Jun 24, 2003, in forum: VHDL
    Replies:
    0
    Views:
    2,492
    Paul Leventis
    Jun 24, 2003
  5. Matthew
    Replies:
    7
    Views:
    742
    Priscilla Walmsley
    Jan 7, 2005
Loading...

Share This Page