Asp form and user input

Dear Experts,

I need a bit help for solving this issue.

Theoretically the code is correct ( think), but is does not works properly.

I have 2 files: 1 html file

<form type="GET"  action="DROPDOWNDATABASEX.asp">
<input type="text" name="look_for"  value="http://www.filosofia.org/rev/bas/bas10115.htm">
<input type="submit"  value="Submit">
</form>

Open in new window


and 1 .asp file:
Dim strKeyword,look_for
	 strKeyword = Request.QueryString("look_for")
response.write strKeyword & "<br>" 


rs.open "SELECT * FROM add0 where url like 'strKeyword'  ",con

Open in new window


The message I read after running:

response.write strKeyword = http://www.filosofia.org/rev/bas/bas10115.htm

So it understand what is "strkeyword", but when I use SELECT it does the following message:

Sorry, no matching record was found.

BUT IN DATABASE THE THERE IS A REGISTER = THIS URL  !!!

If I use

rs.open "SELECT * FROM add0 where url = 'strKeyword'  ",con

Open in new window

= Sorry, no matching record was found.

However, evidently If I use

rs.open "SELECT * FROM add0 where url = "'&strKeyword&'"  ",con

Open in new window


It gives all entries with urls of the database, but I need the exactly url I entered!!!


Please, could someone help me?

Thanks

Bob K.
BOB KUSPEAsked:
Who is Participating?
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
looking on my phone, I missed the incorrect placement of the single quotes, it should be:

rs.open "SELECT * FROM add0 where url = '" & strKeyword & "'",con

Open in new window

1
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Your second query is what you want to use, your first query is asking for records where url equals the string "keywords", which obviously doesn't exist. You're not concatenating the string in your first query.
1
 
BOB KUSPEAuthor Commented:
Dear Big Monty


It exists:

url.jpg
1
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Re-read what I wrote, your first query is looking for the string 'strKeyword'
0
 
BOB KUSPEAuthor Commented:
The address bar:

url2.jpg
In the body the url is shown due to response.write strKeyword

but below is the error message regarding the SELECT * from ADD0
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
What is wrong with using the 2nd query is it returns what you're looking for?
0
 
BOB KUSPEAuthor Commented:
Yes, but strKeyword is the variable:
strKeyword = Request.QueryString("look_for")

Open in new window


The way I wrote is not correct?

I need a variable here after url = what would be the exact match, but "accepts" only the wildcard =
"'&strKeyword&'"

Open in new window


Sincerely speaking I dont know what I am doing wrong.

Thank you for your attention
0
 
BOB KUSPEAuthor Commented:
The " wrong with using the 2nd query" it returns all records from field = URL and not exactly what I am looking for
0
 
BOB KUSPEAuthor Commented:
Thank you Big Monty

I don´t understand anymore really... but before reading your last reply I tested and this select are working fine !!!

It output the only the url I submit

rs.open "SELECT fileid, url,texts FROM add0 where url like '%" & strKeyword & "%' ", con

Open in new window


Thank you again
0
 
BOB KUSPEAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.