Results 1 to 14 of 14
  1. #1
    Join Date
    Sep 2009
    Posts
    21

    Talking Unanswered: ASP Image Question

    Alright I have 8 images on a page. I have a couple of companies labeled 1 through 8 and I need to drag information depending on the company from a database I have the code written for the information to come out of the database. What I need to know is how to make it so I can pass number 1 through 8 on to the other page so I can reference it in my code.

    So:

    Image - click on 1 of the 8 images.

    if you click on image 1 it takes the number 1 brings it to another asp page and inserts it into the while statement so only information pertaining to that company comes up. Again I have the code written for the while statement on another page I just need to pass that image number on to the while statement asp page. I know you can do this in php by using a session but is there something similar in asp? I just need the number 1 in a field so I can type.

    WHERE tProductType.lID = numberofimage
    Last edited by bingo_barns; 09-09-09 at 13:54.

  2. #2
    Join Date
    May 2009
    Posts
    258
    Just use the querystring:
    Code:
    http://somesite.com/details.asp?num=1
    Then obtain the value on the next page as:
    Code:
    num = Request.QueryString("num")
    Ax

  3. #3
    Join Date
    Sep 2009
    Posts
    21
    So is that done in basic html as an a href or do I open up my tags for asp? I'm extremely new to asp only been using it for 3 days.

  4. #4
    Join Date
    May 2009
    Posts
    258
    The URL will be in the image link anchor tag (e.g. <a href="...). Obtaining the querystring variable will need to be done within server-side scripting (<%...%>).

  5. #5
    Join Date
    Sep 2009
    Posts
    21
    Dandy man, I appreciate the help!

  6. #6
    Join Date
    May 2009
    Posts
    258
    No problem!

  7. #7
    Join Date
    Sep 2009
    Posts
    21
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'num'.

    /vendors.asp, line 17

    I'm getting this error though

  8. #8
    Join Date
    Sep 2009
    Posts
    21
    num = Request.QueryString("num")


    sql ="SELECT tVendor.sVendorName," &_
    " tVendorType.sVendorTypeDesc,tVendor.sVendorImg,tVe ndor.sVendorWebsite,tProductType.lID" &_
    " FROM tVendor INNER JOIN tVendorType ON tVendor.lid = tVendorType.lVendorID" &_
    " INNER JOIN tProductType ON tVendorType.lProductTypeID = tProductType.lID" &_
    " WHERE tProductType.lID = num"

  9. #9
    Join Date
    May 2009
    Posts
    258
    Change it to:
    Code:
    sql ="SELECT tVendor.sVendorName," & _ 
    " tVendorType.sVendorTypeDesc,tVendor.sVendorImg,tVendor.sVendorWebsite,tProductType.lID" & _
    " FROM tVendor INNER JOIN tVendorType ON tVendor.lid = tVendorType.lVendorID" & _
    " INNER JOIN tProductType ON tVendorType.lProductTypeID = tProductType.lID" & _
    " WHERE tProductType.lID = " & num

  10. #10
    Join Date
    Sep 2009
    Posts
    21
    hahaha! thank you! god love ya!

  11. #11
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I suggest you change it to a stored procedure or at the very least a parameterised query! That is very easy to SQL Inject
    George
    Home | Blog

  12. #12
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I think now would be a VERY good time to walk ALL THE WAY through a good classic asp tutorial. You're treading in dangerous territory.

    This one isn't too bad:

    ASP Tutorial
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  13. #13
    Join Date
    May 2009
    Posts
    258
    My solution was not meant to be a complete solution. To prevent the risk of SQL injection, just make sure to check whether the query string parameter is numeric (hint: use the IsNumeric function). You can then handle a non-numeric parameter accordingly (display an error or redirect back to image selection page).

    Ax

  14. #14
    Join Date
    Sep 2009
    Posts
    21
    Ok, I will do that Ax238. I definitely do need to read up on asp also.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •