"convert" a querystring?

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/65615?pagenum=1
05 November 2025, 09:23

Topic


tribaliztic
"convert" a querystring?
19 September 2007, 08:03


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? =)
<

 

Replies ...


Shaggy
19 September 2007, 08:28


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
<
tribaliztic
19 September 2007, 08:45


Hm... when I added that code I got a 404-error on the page =)
<
Shaggy
19 September 2007, 08:47


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.
<
tribaliztic
19 September 2007, 08:58


The page takes forever to load and then nothing happens. I've mailed link to you.. <
Shaggy
19 September 2007, 09:12


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.
<
tribaliztic
20 September 2007, 02:26


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
20 September 2007, 03:08


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! <
Shaggy
20 September 2007, 04:39


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.
<
tribaliztic
20 September 2007, 04:44


Okay, it's just me being a n00b, sorry =)
<
© 2000-2021 Snitz™ Communications