If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP Image Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-09-09, 12:44
bingo_barns bingo_barns is offline
Registered User
 
Join Date: Sep 2009
Posts: 21
Talking 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 12:54.
Reply With Quote
  #2 (permalink)  
Old 09-09-09, 13:28
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
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
Reply With Quote
  #3 (permalink)  
Old 09-09-09, 13:31
bingo_barns bingo_barns is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 09-09-09, 13:34
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
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 (<%...%>).
Reply With Quote
  #5 (permalink)  
Old 09-09-09, 13:35
bingo_barns bingo_barns is offline
Registered User
 
Join Date: Sep 2009
Posts: 21
Dandy man, I appreciate the help!
Reply With Quote
  #6 (permalink)  
Old 09-09-09, 13:38
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
No problem!
Reply With Quote
  #7 (permalink)  
Old 09-09-09, 13:40
bingo_barns bingo_barns is offline
Registered User
 
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
Reply With Quote
  #8 (permalink)  
Old 09-09-09, 13:44
bingo_barns bingo_barns is offline
Registered User
 
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"
Reply With Quote
  #9 (permalink)  
Old 09-09-09, 13:47
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
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
Reply With Quote
  #10 (permalink)  
Old 09-09-09, 13:49
bingo_barns bingo_barns is offline
Registered User
 
Join Date: Sep 2009
Posts: 21
hahaha! thank you! god love ya!
Reply With Quote
  #11 (permalink)  
Old 09-10-09, 04:36
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #12 (permalink)  
Old 09-10-09, 09:01
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,071
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? ***
Reply With Quote
  #13 (permalink)  
Old 09-10-09, 09:25
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
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
Reply With Quote
  #14 (permalink)  
Old 09-10-09, 09:27
bingo_barns bingo_barns is offline
Registered User
 
Join Date: Sep 2009
Posts: 21
Ok, I will do that Ax238. I definitely do need to read up on asp also.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On