replace:
Code:
<a href="prepare.asp?sub=<%=replace(strOver, vbCrLf, "+")%></a>
with:
Code:
<a href="prepare.asp?sub=<%=server.URLEncode(strOver)%></a>
replace:
Code:
session("psub") = replace(Request.QueryString("sub"), "+", vbCrLf)
with:
Code:
session("psub") = Request.QueryString("sub")
or for a more secure application:
Code:
session("psub") = replace(replace(replace(Request.QueryString("sub"),"\'","'") , "'", "''"), "--", "")
(these are not the only troublesome strings that may invade your SQL statement - so check this out in more detail)
then replace this:
Code:
strSQL = "SELECT * FROM tblExperts WHERE tblExperts.Subject_Area = '" & Server.HtmlEncode(session("psub") )& "';"
with:
Code:
strSQL = "SELECT * FROM tblExperts WHERE tblExperts.Subject_Area = '" & session("psub") & "';"
(we've taken care of some of the unlikeable values whilst reading the raw user input)
This does rely on the fact that the value being passed is actually the same as something in the database. Which means it has to have been INSERTed to the DB with a CRLF... Why would you have a subject area with a CRLF in it ? Of course, it's possible - just seems a little unusual to me.
As per DNG's suggestion - do a: response.write strSQL
and look at the result - check if the value in the WHERE clause is in the database field you expect.
Also, not sure why you have the intermediary page 'prepare.asp' - do you need it ? if you do, then for better performance, you may want to try server.transfer, unless prepare.asp has something to send to the user.
Also, the where clause is looking for a long description as part of the search,... why? This seems terribly inefficient? If it is just user input then it is unlikely to work for that many keywords, if it is automatic from another page, why not just use the ID for the record ? or just the other elements, which are similarly interesting, yet much shorter..
whatever generated that string needs to keep the crlf - if you want to add them you can do so using the Chr(13) & chr(10) to add in the string. If they were there originally then you are probably stripping them out somewhere..
A smile is worth a thousand kind words. So smile, it's easy! 