PDA

Click to See Complete Forum and Search --> : Variable Comparisons ...


Randhart
Feb 28th, 2001, 05:44 AM
Hey Guy's ..

Yes it it I ... Again :D .... With another problem for the Dev-Demmie-Gods ;)

So to begin here's my code:
*************
'Checks the Session Variable "State" to see if user used correct route to enter the Site'

chSession = Trim(Session("state"))
chString = Trim(Request.Querystring("sStatus"))

if chSession <> chString then
Response.Write "It didn't worked"
Response.End
'Response.Redirect "http://www.newsclip.co.za/asp/temp.html"
Else
Response.Write "It worked<br>"
End If
*************

Now what this code is supposed to to is this ....
The Session("status") is a Random number red into the Session ("status") variable ...the same variable is read into the Querystring .. the idea behind this is that a User has to through a certain page so that the Audit trail can be invoked.

Now my problem is that no matter what opperator I use = or <> I can't seem to be able to compare them .. I wrote them into the same page and they are the same .. In thought that there might be a problem with Spaces that's why i used the Trim() ..

You can test this here:
http://www.newsclip.co.za/clients.asp

Thanks in Advance!

sebs
Feb 28th, 2001, 07:16 AM
hummm
try converting them to string:

if CStr(chSession) <> CStr(chString) then

Mark Sreeves
Feb 28th, 2001, 08:05 AM
This works:



<%@ Language=VBScript %>
<html>
<body>

<%
chSession = Trim(Session("state"))
chString = Trim(Request("sStatus"))

Response.Write chSession & "<BR>"
Response.Write chString & "<BR>"

if chSession = chString then

Response.Write "It worked<br>"

Else
Response.Write "It didn't work"
End If
%>

</BODY>
</HTML>

Randhart
Mar 1st, 2001, 12:20 AM
Thanks Guy's :cool:

It worked out perfectly!!!! .. I combined both of your solutions!!!

Cheers vir eers!

Mark Sreeves
Mar 1st, 2001, 02:25 AM
Okey dokey!

The problem was your syntax in Request.Querystring("sStatus")) which was returning and empty string when I tried it.

converting them to strings as well is probably not necsesary.