Forum Moderators: open
The index code is:-
<a href="build.asp?product=<%=(rs_products.Fields.Item("product_display_title").Value)%
so the product is held in the URL, and passed to the buils.asp page.
I have the following SELECT code in a file called "build.asp" which i need to capture the "product", from the index.asp code
SELECT * FROM components, products WHERE componentt_title LIKE 'Processor' AND product_display_title = '" + product + "'
the trouble is, im getting mixed up with my variables and not sure what to do with them? As i understand i need
var product=Request.Querystring("product") within my build.asp code.
But i get an error, and also do i need to declare this variable in my index.asp, and if so what is the format?
hope you all understand,
trying to get to grips with this ASP
Andy
dim product
product=Request.Querystring("product") 'within my build.asp code.
instead of
var product=Request.Querystring("product") within my build.asp code.
var is a javascript declaration and you identified the scripting language at the top of the page:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
as VBScript.
I would also use more descriptive variable names. It will help when you are looking at a hundred of them.
If it was me I'd do it like this;
SELECT * FROM components, products WHERE componentt_title LIKE 'Processor' AND product_display_title = '" & Request.Querystring("product") & "'
This doesn't require an extra variable, therefore no declarations. I also swapped the +'s for &'s since if you are working with text with ASP the & is preferable.
You might want to consider filtering the input first rather than using it as-is, maybe wrapping it in a function call to do the entire thing inline. (See the PHP Security thread for an explanation of why you need to do this - the case outlined there applies to any script language including ASP)
To declare & use a variable
Dim sMyString
sMyString = "Something"
sMyString = Object.Property
Sadly you can't use a single variable creation and assignment as you can in C or JavaScript.
Hope that helps.
- Tony