"convert" a querystring? - Posted (1054 Views)
Senior Member
tribaliztic
Posts: 1532
1532
How can I "convert" a querystring?
I have a modded version of Marcel's blog mod and it use the querystring "log_id". However there are some autogenerated links that point to the blog mod with the old "TOPIC_ID" querystring...
I tried this:

if not Request.QueryString("TOPIC_ID") = "" then
T_ID = Request.QueryString("log_id")
Response.Write(" T_ID ")
Response.Redirect("grarticles.asp?log_id=T_ID")
end if

but that didn't work, why? =)
<
/Tribaliztic
- www.gotlandrace.se -
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Support Moderator
Shaggy
Posts: 6780
6780
Code:
T_ID=request.querystring("log_id")
if len(T_ID)=0 or not isnumeric(T_ID) then T_ID=request.querystring("TOPIC_ID")
if len(T_ID)>0 and isnumeric(T_ID) then
' response.write T_ID
response.redirect "grarticles.asp?log_id="&T_ID
else
response.write "Error"
end if
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Senior Member
tribaliztic
Posts: 1532
1532
Hm... when I added that code I got a 404-error on the page =)
<
/Tribaliztic
- www.gotlandrace.se -
Posted
Support Moderator
Shaggy
Posts: 6780
6780
Sure it's a 404 & not a 500? Got Linkage? Deleted the "dim T_ID" line above as it's not really necessary and may be the cause of a 500 error.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Senior Member
tribaliztic
Posts: 1532
1532
The page takes forever to load and then nothing happens. I've mailed link to you.. <
/Tribaliztic
- www.gotlandrace.se -
Posted
Support Moderator
Shaggy
Posts: 6780
6780
Go it, didn't realise you were placing this code on the page you were redirecting to so what I gave you was creating an infinite loop.
Here's the code you need:
Code:
T_ID=request.querystring("log_id")
if len(T_ID)=0 or not isnumeric(T_ID) then T_ID=request.querystring("TOPIC_ID")
if len(T_ID)>0 and isnumeric(T_ID) then
response.write "Code"
else
response.write "Error"
end if
There's actually no need for the redirect, just be sure to reference T_ID everywhere within your code. The "Code" I've highlighted in green above is where you place the code for your page, the "Error" is whatever error you want to present to members if T_ID is not valid, i.e., it's empty or doesn't have a numeric value.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Senior Member
tribaliztic
Posts: 1532
1532
Hm.. you mean I should replace all instances of:
cLng(Request.QueryString("log_id")
with
T_ID
? This will probably mess things up for me, can't I just make cLng(Request.QueryString("log_id") understand what's in the cLng(Request.QueryString("TOPIC_ID") ? =)
<
/Tribaliztic
- www.gotlandrace.se -
Posted
Senior Member
tribaliztic
Posts: 1532
1532
I did another workaround =)

On topic.asp I added this:

strSQL7 = "SELECT FORUM_ID FROM FORUM_TOPICS WHERE TOPIC_ID = " & cLng(Request.Querystring("TOPIC_ID")) & ""
set ARTrs = Server.CreateObject("ADODB.Recordset")
ARTrs.open strSQL7, strConnString
if not ARTrs.EOF then
if ARTrs("FORUM_ID") = 85 then
Response.Redirect("grarticles.asp?log_id=" & cLng(Request.Querystring("TOPIC_ID")) & "")
end if
end if
ARTrs.close

To check if the topic is supposed to be an article, then redirect to the article mod.
This soled my problem, but maybe not in the best way =)

Thanks Shaggy for your time! <
/Tribaliztic
- www.gotlandrace.se -
Posted
Support Moderator
Shaggy
Posts: 6780
6780
Originally posted by tribaliztic ... can't I just make cLng(Request.QueryString("log_id") understand what's in the cLng(Request.QueryString("TOPIC_ID") ?
That's what my code does, assigning the value to a variable. Replacing all occurrences of request.querystring("log_id") with T_ID in your code shouldn't have messed anything up for you but, if you've found another way around it that works for you, fair enough.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Senior Member
tribaliztic
Posts: 1532
1532
Okay, it's just me being a n00b, sorry =)
<
/Tribaliztic
- www.gotlandrace.se -
 
You Must enter a message